//---------------------------------------------------------------------
// This confidential and proprietary software may be used only as
// authorized by a licensing agreement from nSys
// In the event of publication, the following notice is applicable:
//
// (C) Copyright 2001-2010 nSys
// All rights reserved
//
// The entire notice above must be reproduced on all authorized copies
//
// Model Name     : PCI Express
// Module         : nvs_ex_top
// Tasks          : assign_handle,set_msg_debug
// Function       : None
//
// $Source: /tmp/nsys_ex_gen3.v/sim/nvs_ex_top.v,v $
// $Author: udit $
// $Date: 2010-06-08 06:39:26 $
// $Revision: 1.37 $
// Identification : NSYS/PCIEX/COD/EXTOP
// Abstract       : This module represents the top module which
//                  instantiates Bfms,monitors and checkers.
//
// Packages/module called (if any ):  none
//
// Platforms and tool version used : Red Hat Linux ver 7.2, NC-SIM 4.1 
//
// The file defines the module nvs_ex_top. The module provides two 32 
// lanes ,link configuration.
// For link 1 the signals are defined as
// tx0 to tx31 for Tx lanes
// rx0 to rx31 for Rx lanes
// The default settings in this link configuration(EXTEST) creates an
// instance of BFM configured as RC and other instance configured as EP.
// These instances  are
// Bfm0   : RC instance of nvs_ex_bfm
// Bfm1   : EP instance of nvs_ex_bfm
// Checker and Monitor are instantiated as
// Checker: Checker instance on the link
// Monitor: Monitor instance on the link
// In other configurations(EX_TEST_DUT_UPSTREAM_PORT,EX_TEST_DUT_DOWNSTREAM_PORT),
// user can enable any one of the bfm instance.The same is explained in User
// Manual section 1.6.

// For link 2 the signal are defined as
// tx0_0 to tx0_31 for Tx lanes
// rx0_0 to rx_031 for Rx lanes
// The default settings in this configuration creates an instance
// of BFM configured as down stream switch and other instance configured
// as EP.These instances are 
// Bfm2: Down stream switch instance of nvs_ex_bfm
// Bfm3: EP instance of nvs_ex_bfm
// Checker and Monitor are instantiated as
// Checker1: Checker instance on the link
// Monitor1: Monitor instance on the link
// Link 2 is only complied if EX_MULTI is defined
//
// The module provides clock generation logic and passes file handle to
// all nvs components. 
//----------------------------------------------------------------------
`timescale 100ps/100fs                    //time scale
//----------------------------------------------------------------------
// INCLUDE FILES
//----------------------------------------------------------------------
`ifdef EX_PROTECT
 `include "nvs_ex.hp"
`else
 `include "nvs_ex.h"
`endif

//`define INSERT_SB
module nvs_ex_top;              

   
  reg clk8000 = 1'b1;
  reg clk4000 = 1'b1;
  reg clk2000 = 1'b1;
  reg clk1000 = 1'b1;
  reg clk500 = 1'b1;
  reg clk250 = 1'b1;
  reg clk125 = 1'b1;
  reg clk200 = 1'b1;
  reg clk5000 = 1'b1;
  reg clk2500 = 1'b1;

  wire  rc_clk;
  wire  rc_speed_gen2;
  wire  rc_speed_gen3;
  wire  ep_clk;
  wire  ep_speed_gen2;
  wire  ep_speed_gen3;
  
  reg   rst;
  wire  clk = rc_clk; //clk is used in nvs_ex_top_task.vihp
  
  wire [9:0]  rc_tx0;
  wire [9:0]  rc_tx1;
  wire [9:0]  rc_tx2;
  wire [9:0]  rc_tx3;
  wire [9:0]  rc_tx4;
  wire [9:0]  rc_tx5;
  wire [9:0]  rc_tx6;
  wire [9:0]  rc_tx7;
  wire [9:0]  rc_tx8;
  wire [9:0]  rc_tx9;
  wire [9:0]  rc_tx10;
  wire [9:0]  rc_tx11;
  wire [9:0]  rc_tx12;
  wire [9:0]  rc_tx13;
  wire [9:0]  rc_tx14;
  wire [9:0]  rc_tx15;
  wire [9:0]  rc_tx16;
  wire [9:0]  rc_tx17;
  wire [9:0]  rc_tx18;   
  wire [9:0]  rc_tx19;
  wire [9:0]  rc_tx20;
  wire [9:0]  rc_tx21;
  wire [9:0]  rc_tx22;
  wire [9:0]  rc_tx23;
  wire [9:0]  rc_tx24;
  wire [9:0]  rc_tx25;
  wire [9:0]  rc_tx26;
  wire [9:0]  rc_tx27;
  wire [9:0]  rc_tx28;
  wire [9:0]  rc_tx29;
  wire [9:0]  rc_tx30;
  wire [9:0]  rc_tx31;   

  wire [9:0]  rc_rx0;   
  wire [9:0]  rc_rx1;
  wire [9:0]  rc_rx2;
  wire [9:0]  rc_rx3;
  wire [9:0]  rc_rx4;
  wire [9:0]  rc_rx5;
  wire [9:0]  rc_rx6;
  wire [9:0]  rc_rx7;
  wire [9:0]  rc_rx8;
  wire [9:0]  rc_rx9;
  wire [9:0]  rc_rx10;
  wire [9:0]  rc_rx11;
  wire [9:0]  rc_rx12;
  wire [9:0]  rc_rx13;
  wire [9:0]  rc_rx14;
  wire [9:0]  rc_rx15;
  wire [9:0]  rc_rx16;
  wire [9:0]  rc_rx17;
  wire [9:0]  rc_rx18;   
  wire [9:0]  rc_rx19;
  wire [9:0]  rc_rx20;
  wire [9:0]  rc_rx21;
  wire [9:0]  rc_rx22;
  wire [9:0]  rc_rx23;
  wire [9:0]  rc_rx24;
  wire [9:0]  rc_rx25;
  wire [9:0]  rc_rx26;
  wire [9:0]  rc_rx27;
  wire [9:0]  rc_rx28;
  wire [9:0]  rc_rx29;
  wire [9:0]  rc_rx30;
  wire [9:0]  rc_rx31;   

  wire [1:0]  sb_up_Rate;
  wire [2:0]  sb_up_PCLK_Rate;
  wire [1:0]  sb_up_Width;
  wire 		    sb_up_Reset_n;
  wire [1:0]  sb_up_PowerDown;
  wire 		    sb_up_TxDetectRxLoopback;
  wire        sb_up_pclk;
  wire [31:0] sb_up_TxData0;
  wire [31:0] sb_up_TxData1;
  wire [31:0] sb_up_TxData2;
  wire [31:0] sb_up_TxData3;
  wire [31:0] sb_up_TxData4;
  wire [31:0] sb_up_TxData5;
  wire [31:0] sb_up_TxData6;
  wire [31:0] sb_up_TxData7;
  wire [31:0] sb_up_TxData8;
  wire [31:0] sb_up_TxData9;
  wire [31:0] sb_up_TxData10;
  wire [31:0] sb_up_TxData11;
  wire [31:0] sb_up_TxData12;
  wire [31:0] sb_up_TxData13;
  wire [31:0] sb_up_TxData14;
  wire [31:0] sb_up_TxData15;
  wire [3:0]  sb_up_TxDataK0;
  wire [3:0]  sb_up_TxDataK1;
  wire [3:0]  sb_up_TxDataK2;
  wire [3:0]  sb_up_TxDataK3;
  wire [3:0]  sb_up_TxDataK4;
  wire [3:0]  sb_up_TxDataK5;
  wire [3:0]  sb_up_TxDataK6;
  wire [3:0]  sb_up_TxDataK7;
  wire [3:0]  sb_up_TxDataK8;
  wire [3:0]  sb_up_TxDataK9;
  wire [3:0]  sb_up_TxDataK10;
  wire [3:0]  sb_up_TxDataK11;
  wire [3:0]  sb_up_TxDataK12;
  wire [3:0]  sb_up_TxDataK13;
  wire [3:0]  sb_up_TxDataK14;
  wire [3:0]  sb_up_TxDataK15;
  wire        sb_up_TxDataValid0;
  wire        sb_up_TxDataValid1;
  wire        sb_up_TxDataValid2;
  wire        sb_up_TxDataValid3;
  wire        sb_up_TxDataValid4;
  wire        sb_up_TxDataValid5;
  wire        sb_up_TxDataValid6;
  wire        sb_up_TxDataValid7;
  wire        sb_up_TxDataValid8;
  wire        sb_up_TxDataValid9;
  wire        sb_up_TxDataValid10;
  wire        sb_up_TxDataValid11;
  wire        sb_up_TxDataValid12;
  wire        sb_up_TxDataValid13;
  wire        sb_up_TxDataValid14;
  wire        sb_up_TxDataValid15;
  wire        sb_up_TxStartBlock0;
  wire        sb_up_TxStartBlock1;
  wire        sb_up_TxStartBlock2;
  wire        sb_up_TxStartBlock3;
  wire        sb_up_TxStartBlock4;
  wire        sb_up_TxStartBlock5;
  wire        sb_up_TxStartBlock6;
  wire        sb_up_TxStartBlock7;
  wire        sb_up_TxStartBlock8;
  wire        sb_up_TxStartBlock9;
  wire        sb_up_TxStartBlock10;
  wire        sb_up_TxStartBlock11;
  wire        sb_up_TxStartBlock12;
  wire        sb_up_TxStartBlock13;
  wire        sb_up_TxStartBlock14;
  wire        sb_up_TxStartBlock15;
  wire        sb_up_TxElecIdle0;
  wire        sb_up_TxElecIdle1;
  wire        sb_up_TxElecIdle2;
  wire        sb_up_TxElecIdle3;
  wire        sb_up_TxElecIdle4;
  wire        sb_up_TxElecIdle5;
  wire        sb_up_TxElecIdle6;
  wire        sb_up_TxElecIdle7;
  wire        sb_up_TxElecIdle8;
  wire        sb_up_TxElecIdle9;
  wire        sb_up_TxElecIdle10;
  wire        sb_up_TxElecIdle11;
  wire        sb_up_TxElecIdle12;
  wire        sb_up_TxElecIdle13;
  wire        sb_up_TxElecIdle14;
  wire        sb_up_TxElecIdle15;
  wire        sb_up_TxCompliance0;
  wire        sb_up_TxCompliance1;
  wire        sb_up_TxCompliance2;
  wire        sb_up_TxCompliance3;
  wire        sb_up_TxCompliance4;
  wire        sb_up_TxCompliance5;
  wire        sb_up_TxCompliance6;
  wire        sb_up_TxCompliance7;
  wire        sb_up_TxCompliance8;
  wire        sb_up_TxCompliance9;
  wire        sb_up_TxCompliance10;
  wire        sb_up_TxCompliance11;
  wire        sb_up_TxCompliance12;
  wire        sb_up_TxCompliance13;
  wire        sb_up_TxCompliance14;
  wire        sb_up_TxCompliance15;
  wire        sb_up_RxPolarity0;
  wire        sb_up_RxPolarity1;
  wire        sb_up_RxPolarity2;
  wire        sb_up_RxPolarity3;
  wire        sb_up_RxPolarity4;
  wire        sb_up_RxPolarity5;
  wire        sb_up_RxPolarity6;
  wire        sb_up_RxPolarity7;
  wire        sb_up_RxPolarity8;
  wire        sb_up_RxPolarity9;
  wire        sb_up_RxPolarity10;
  wire        sb_up_RxPolarity11;
  wire        sb_up_RxPolarity12;
  wire        sb_up_RxPolarity13;
  wire        sb_up_RxPolarity14;
  wire        sb_up_RxPolarity15;
  wire [1:0]  sb_up_TxSyncHeader0;
  wire [1:0]  sb_up_TxSyncHeader1;
  wire [1:0]  sb_up_TxSyncHeader2;
  wire [1:0]  sb_up_TxSyncHeader3;
  wire [1:0]  sb_up_TxSyncHeader4;
  wire [1:0]  sb_up_TxSyncHeader5;
  wire [1:0]  sb_up_TxSyncHeader6;
  wire [1:0]  sb_up_TxSyncHeader7;
  wire [1:0]  sb_up_TxSyncHeader8;
  wire [1:0]  sb_up_TxSyncHeader9;
  wire [1:0]  sb_up_TxSyncHeader10;
  wire [1:0]  sb_up_TxSyncHeader11;
  wire [1:0]  sb_up_TxSyncHeader12;
  wire [1:0]  sb_up_TxSyncHeader13;
  wire [1:0]  sb_up_TxSyncHeader14;
  wire [1:0]  sb_up_TxSyncHeader15;
  wire [2:0]  sb_up_TxMargin;                            
  wire [17:0] sb_up_TxDeemph;                            

  wire [31:0] sb_up_RxData0;
  wire [31:0] sb_up_RxData1;
  wire [31:0] sb_up_RxData2;
  wire [31:0] sb_up_RxData3;
  wire [31:0] sb_up_RxData4;
  wire [31:0] sb_up_RxData5;
  wire [31:0] sb_up_RxData6;
  wire [31:0] sb_up_RxData7;
  wire [31:0] sb_up_RxData8;
  wire [31:0] sb_up_RxData9;
  wire [31:0] sb_up_RxData10;
  wire [31:0] sb_up_RxData11;
  wire [31:0] sb_up_RxData12;
  wire [31:0] sb_up_RxData13;
  wire [31:0] sb_up_RxData14;
  wire [31:0] sb_up_RxData15;
  wire [3:0]  sb_up_RxDataK0;
  wire [3:0]  sb_up_RxDataK1;
  wire [3:0]  sb_up_RxDataK2;
  wire [3:0]  sb_up_RxDataK3;
  wire [3:0]  sb_up_RxDataK4;
  wire [3:0]  sb_up_RxDataK5;
  wire [3:0]  sb_up_RxDataK6;
  wire [3:0]  sb_up_RxDataK7;
  wire [3:0]  sb_up_RxDataK8;
  wire [3:0]  sb_up_RxDataK9;
  wire [3:0]  sb_up_RxDataK10;
  wire [3:0]  sb_up_RxDataK11;
  wire [3:0]  sb_up_RxDataK12;
  wire [3:0]  sb_up_RxDataK13;
  wire [3:0]  sb_up_RxDataK14;
  wire [3:0]  sb_up_RxDataK15;
  wire        sb_up_RxDataValid0;
  wire        sb_up_RxDataValid1;
  wire        sb_up_RxDataValid2;
  wire        sb_up_RxDataValid3;
  wire        sb_up_RxDataValid4;
  wire        sb_up_RxDataValid5;
  wire        sb_up_RxDataValid6;
  wire        sb_up_RxDataValid7;
  wire        sb_up_RxDataValid8;
  wire        sb_up_RxDataValid9;
  wire        sb_up_RxDataValid10;
  wire        sb_up_RxDataValid11;
  wire        sb_up_RxDataValid12;
  wire        sb_up_RxDataValid13;
  wire        sb_up_RxDataValid14;
  wire        sb_up_RxDataValid15;
  wire        sb_up_RxValid0;
  wire        sb_up_RxValid1;
  wire        sb_up_RxValid2;
  wire        sb_up_RxValid3;
  wire        sb_up_RxValid4;
  wire        sb_up_RxValid5;
  wire        sb_up_RxValid6;
  wire        sb_up_RxValid7;
  wire        sb_up_RxValid8;
  wire        sb_up_RxValid9;
  wire        sb_up_RxValid10;
  wire        sb_up_RxValid11;
  wire        sb_up_RxValid12;
  wire        sb_up_RxValid13;
  wire        sb_up_RxValid14;
  wire        sb_up_RxValid15;
  wire        sb_up_RxElecIdle0;
  wire        sb_up_RxElecIdle1;
  wire        sb_up_RxElecIdle2;
  wire        sb_up_RxElecIdle3;
  wire        sb_up_RxElecIdle4;
  wire        sb_up_RxElecIdle5;
  wire        sb_up_RxElecIdle6;
  wire        sb_up_RxElecIdle7;
  wire        sb_up_RxElecIdle8;
  wire        sb_up_RxElecIdle9;
  wire        sb_up_RxElecIdle10;
  wire        sb_up_RxElecIdle11;
  wire        sb_up_RxElecIdle12;
  wire        sb_up_RxElecIdle13;
  wire        sb_up_RxElecIdle14;
  wire        sb_up_RxElecIdle15;
  wire [2:0]  sb_up_RxStatus0;
  wire [2:0]  sb_up_RxStatus1;
  wire [2:0]  sb_up_RxStatus2;
  wire [2:0]  sb_up_RxStatus3;
  wire [2:0]  sb_up_RxStatus4;
  wire [2:0]  sb_up_RxStatus5;
  wire [2:0]  sb_up_RxStatus6;
  wire [2:0]  sb_up_RxStatus7;
  wire [2:0]  sb_up_RxStatus8;
  wire [2:0]  sb_up_RxStatus9;
  wire [2:0]  sb_up_RxStatus10;
  wire [2:0]  sb_up_RxStatus11;
  wire [2:0]  sb_up_RxStatus12;
  wire [2:0]  sb_up_RxStatus13;
  wire [2:0]  sb_up_RxStatus14;
  wire [2:0]  sb_up_RxStatus15;
  wire        sb_up_RxStartBlock0;
  wire        sb_up_RxStartBlock1;
  wire        sb_up_RxStartBlock2;
  wire        sb_up_RxStartBlock3;
  wire        sb_up_RxStartBlock4;
  wire        sb_up_RxStartBlock5;
  wire        sb_up_RxStartBlock6;
  wire        sb_up_RxStartBlock7;
  wire        sb_up_RxStartBlock8;
  wire        sb_up_RxStartBlock9;
  wire        sb_up_RxStartBlock10;
  wire        sb_up_RxStartBlock11;
  wire        sb_up_RxStartBlock12;
  wire        sb_up_RxStartBlock13;
  wire        sb_up_RxStartBlock14;
  wire        sb_up_RxStartBlock15;
  wire [1:0]  sb_up_RxSyncHeader0;
  wire [1:0]  sb_up_RxSyncHeader1;
  wire [1:0]  sb_up_RxSyncHeader2;
  wire [1:0]  sb_up_RxSyncHeader3;
  wire [1:0]  sb_up_RxSyncHeader4;
  wire [1:0]  sb_up_RxSyncHeader5;
  wire [1:0]  sb_up_RxSyncHeader6;
  wire [1:0]  sb_up_RxSyncHeader7;
  wire [1:0]  sb_up_RxSyncHeader8;
  wire [1:0]  sb_up_RxSyncHeader9;
  wire [1:0]  sb_up_RxSyncHeader10;
  wire [1:0]  sb_up_RxSyncHeader11;
  wire [1:0]  sb_up_RxSyncHeader12;
  wire [1:0]  sb_up_RxSyncHeader13;
  wire [1:0]  sb_up_RxSyncHeader14;
  wire [1:0]  sb_up_RxSyncHeader15;
  wire        sb_up_PhyStatus; 	   
  wire        sb_up_TxSwing; 

  reg sb_clk;

  wire [3:0]  sb_up_rxp;
  wire [3:0]  sb_up_rxn;
  wire [3:0]  sb_up_txp;
  wire [3:0]  sb_up_txn;
  wire [3:0]  sb_dn_rxp;
  wire [3:0]  sb_dn_rxn;
  wire [3:0]  sb_dn_txp;
  wire [3:0]  sb_dn_txn;
  wire up_linkup;
  wire dn_linkup;

  assign sb_up_rxp[0] = rc_tx0[0] === 1'bx ? 1'b0 : rc_tx0[0] === 1'bz ? 1'b0 : rc_tx0[0];
  assign sb_up_rxn[0] = rc_tx0[0] === 1'bx ? 1'b0 : rc_tx0[0] === 1'bz ? 1'b0 : ~rc_tx0[0];
  assign sb_up_rxp[1] = rc_tx1[0] === 1'bx ? 1'b0 : rc_tx1[0] === 1'bz ? 1'b0 : rc_tx1[0];
  assign sb_up_rxn[1] = rc_tx1[0] === 1'bx ? 1'b0 : rc_tx1[0] === 1'bz ? 1'b0 : ~rc_tx1[0];
  assign sb_up_rxp[2] = rc_tx2[0] === 1'bx ? 1'b0 : rc_tx2[0] === 1'bz ? 1'b0 : rc_tx2[0];
  assign sb_up_rxn[2] = rc_tx2[0] === 1'bx ? 1'b0 : rc_tx2[0] === 1'bz ? 1'b0 : ~rc_tx2[0];
  assign sb_up_rxp[3] = rc_tx3[0] === 1'bx ? 1'b0 : rc_tx3[0] === 1'bz ? 1'b0 : rc_tx3[0];
  assign sb_up_rxn[3] = rc_tx3[0] === 1'bx ? 1'b0 : rc_tx3[0] === 1'bz ? 1'b0 : ~rc_tx3[0];
  assign rc_rx0 = (sb_up_txp[0] === sb_up_txn[0]) ? 10'bz : {9'b0, sb_up_txp[0]};
  assign rc_rx1 = (sb_up_txp[1] === sb_up_txn[1]) ? 10'bz : {9'b0, sb_up_txp[1]};
  assign rc_rx2 = (sb_up_txp[2] === sb_up_txn[2]) ? 10'bz : {9'b0, sb_up_txp[2]};
  assign rc_rx3 = (sb_up_txp[3] === sb_up_txn[3]) ? 10'bz : {9'b0, sb_up_txp[3]};
  assign rc_rx4 = {10'b0};
  assign rc_rx5 = {10'b0};
  assign rc_rx6 = {10'b0};
  assign rc_rx7 = {10'b0};
  assign rc_rx8 = {10'b0};
  assign rc_rx9 = {10'b0};
  assign rc_rx10 = {10'b0};
  assign rc_rx11 = {10'b0};
  assign rc_rx12 = {10'b0};
  assign rc_rx13 = {10'b0};
  assign rc_rx14 = {10'b0};
  assign rc_rx15 = {10'b0};
  assign rc_rx16 = {10'b0};
  assign rc_rx17 = {10'b0};
  assign rc_rx18 = {10'b0};
  assign rc_rx19 = {10'b0};
  assign rc_rx20 = {10'b0};
  assign rc_rx21 = {10'b0};
  assign rc_rx22 = {10'b0};
  assign rc_rx23 = {10'b0};
  assign rc_rx24 = {10'b0};
  assign rc_rx25 = {10'b0};
  assign rc_rx26 = {10'b0};
  assign rc_rx27 = {10'b0};
  assign rc_rx28 = {10'b0};
  assign rc_rx29 = {10'b0};
  assign rc_rx30 = {10'b0};
  assign rc_rx31 = {10'b0};

  InSight #(
    .SIMULATION("TRUE"),
    .LANES(4))
  sb(
    .SYS_CLKp   (clk200),
    .SYS_CLKn   (~clk200),
    .SYS_RST    (rst),
    
    .PCIE_PERSTn  (~rst),
    
    .PCIE_UP_REFCLKp (sb_clk),
    .PCIE_UP_REFCLKn (~sb_clk),
    .PCIE_UP_RXp  (sb_up_rxp),
    .PCIE_UP_RXn  (sb_up_rxn),
    .PCIE_UP_TXp  (sb_up_txp),
    .PCIE_UP_TXn  (sb_up_txn));

  initial
  begin
    sb_clk = 1'b1;
  end
  
  always
  begin
    #50 sb_clk = ~sb_clk;
  end
  
  initial
  begin
    rst = 1'b1;
    #5000;
    rst = 1'b0;
  end

  reg       flg_end_done;
  reg 		  start_test_case;  //used in nvs_ex_ep_pl_gen2_compliance_test.v 
  event 		event_start_test; //Event to start test
  event 		event_end_test;   //Event to finish simulation

  
`ifdef EX_PROTECT
 `include "nvs_ex_top_task.vihp"
`else
 `include "nvs_ex_top_task.vih"
`endif

  defparam 					      `BFM0.EX_NAME               = "BFM0";          // Name of Instance
  defparam 					      `BFM0.EX_DEVICE_TYPE        = `EX_RC;   // Down stream Switch 
  defparam 					      `BFM0.EX_PORT_TYPE          = `EX_DOWNSTREAM; // Down Stream Port
  defparam 					      `BFM0.EX_LANE_COUNT         = 4;           // Setting Lane Coint 
`ifdef SB_UPLINK_IS_PIPE
  defparam 					      `BFM0.EX_TX_WIDTH           = `EX_PARALLEL;
  defparam 					      `BFM0.EX_PIPE               = 1;
  defparam 					      `BFM0.EX_PIPE_IF_16         = 1;
  defparam 					      `BFM0.EX_PIPE_IF_32         = 0;
`else // SB_UPLINK_IS_PIPE
  defparam 					      `BFM0.EX_TX_WIDTH           = `EX_SERIAL; //1-bit interface   
  defparam 					      `BFM0.EX_PIPE               = 0;
  defparam 					      `BFM0.EX_PIPE_IF_16         = 0;
  defparam 					      `BFM0.EX_PIPE_IF_32         = 0;
`endif //SB_UPLINK_IS_PIPE
  defparam 					      `BFM0.EX_HDRFC_DEF_P        = 32;
  defparam 					      `BFM0.EX_HDRFC_DEF_NP       = 32; //header credits in initfc(np)
  defparam 					      `BFM0.EX_HDRFC_DEF_CPL      = 32; //header credits in initfc(cpl)
  defparam 					      `BFM0.EX_DATAFC_DEF_P       = 512;//data credits in initfc(p)
  defparam 					      `BFM0.EX_DATAFC_DEF_NP      = 512;//data credits in initfc(np)
  defparam 					      `BFM0.EX_DATAFC_DEF_CPL     = 512;//data credits in initfc(cpl)
  defparam 					      `BFM0.EX_PL_1ms_TIMEOUT     = 20000;   // For crosslink
  defparam 					      `BFM0.EX_PL_2ms_TIMEOUT     = 35000; 
  defparam 					      `BFM0.EX_PL_24ms_TIMEOUT    = 35000;
  defparam 					      `BFM0.EX_PL_48ms_TIMEOUT    = 35000;
  defparam 					      `BFM0.EX_RC_RCB_64          = `EX_ZERO; // RCB is 64/128
  defparam 					      `BFM0.EX_SCRAM              = `EX_ONE; // Scrambling ON/OFF 
  defparam 					      `BFM0.EX_BFM_MAC            = `EX_ZERO;          // PIPE Interface
  defparam                `BFM0.EX_GEN3_PIPE_WIDTH_CHANGE = 0;

  defparam 					      `MON0.EX_DEV_UP             = `EX_RC;      //Up Stream Device
  defparam 					      `MON0.EX_DEV_DN             = `EX_SW_UP;      //Down Stream Device 
  defparam 					      `MON0.EX_LANE_COUNT         = 4;         // Setting Lane Coint
`ifdef SB_UPLINK_IS_PIPE
  defparam 					      `MON0.EX_TX_WIDTH           = `EX_PARALLEL; //1-bit interface   
  defparam 					      `MON0.EX_PIPE               = 1;
  defparam 					      `MON0.EX_PIPE_IF_16         = 1;
  defparam 					      `MON0.EX_PIPE_IF_32         = 0;
`else // SB_UPLINK_IS_PIPE
  defparam 					      `MON0.EX_TX_WIDTH           = `EX_SERIAL; //1-bit interface   
  defparam 					      `MON0.EX_PIPE               = 0;
  defparam 					      `MON0.EX_PIPE_IF_16         = 0;
  defparam 					      `MON0.EX_PIPE_IF_32         = 0;
`endif //SB_UPLINK_IS_PIPE
  defparam 					      `MON0.EX_SCRAM              = `EX_ONE; // Scrambling ON/OFF

  defparam 					      `CHK0.EX_DEV_UP             = `EX_RC;    //Up Stream Device
  defparam 					      `CHK0.EX_DEV_DN             = `EX_SW_UP;    //Down Stream Device
  defparam 					      `CHK0.EX_RC_PEER            = `EX_ONE;   //RC supporting Peer-Peer
  defparam 					      `CHK0.EX_LANE_COUNT         = 4;         // Setting Lane Coint
  defparam 					      `CHK0.EX_PL_2ms_TIMEOUT     = 35000; 
  defparam 					      `CHK0.EX_PL_24ms_TIMEOUT    = 35000;
  defparam 					      `CHK0.EX_PL_48ms_TIMEOUT    = 35000;
`ifdef SB_UPLINK_IS_PIPE
  defparam 					      `CHK0.EX_TX_WIDTH           = `EX_PARALLEL; //1-bit interface   
  defparam 					      `CHK0.EX_PIPE               = 1;
  defparam 					      `CHK0.EX_PIPE_IF_16         = 1;
  defparam 					      `CHK0.EX_PIPE_IF_32         = 0;
`else // SB_UPLINK_IS_PIPE
  defparam 					      `CHK0.EX_TX_WIDTH           = `EX_SERIAL; //1-bit interface   
  defparam 					      `CHK0.EX_PIPE               = 0;
  defparam 					      `CHK0.EX_PIPE_IF_16         = 0;
  defparam 					      `CHK0.EX_PIPE_IF_32         = 0;
`endif //SB_UPLINK_IS_PIPE
  defparam 					      `CHK0.EX_SCRAM              = `EX_ONE; // Scrambling ON/OFF

  nvs_ex_bfm 
  Bfm0 (
    .tx0		(rc_tx0),
	  .tx1		(rc_tx1),
	  .tx2		(rc_tx2),
	  .tx3		(rc_tx3),
	  .tx4		(rc_tx4),
	  .tx5		(rc_tx5),
	  .tx6		(rc_tx6),
	  .tx7		(rc_tx7),
	  .tx8		(rc_tx8),
	  .tx9		(rc_tx9),
	  .tx10		(rc_tx10),
	  .tx11		(rc_tx11),
	  .tx12		(rc_tx12),
	  .tx13		(rc_tx13),
	  .tx14		(rc_tx14),
	  .tx15		(rc_tx15),
	  .tx16		(rc_tx16),
	  .tx17		(rc_tx17),
	  .tx18		(rc_tx18),
	  .tx19		(rc_tx19),
	  .tx20		(rc_tx20),
	  .tx21		(rc_tx21),
	  .tx22		(rc_tx22),
	  .tx23		(rc_tx23),
	  .tx24		(rc_tx24),
	  .tx25		(rc_tx25),
	  .tx26		(rc_tx26),
	  .tx27		(rc_tx27),
	  .tx28		(rc_tx28),
	  .tx29		(rc_tx29),
	  .tx30		(rc_tx30),
	  .tx31		(rc_tx31),

	  .rx0		(rc_rx0),
	  .rx1		(rc_rx1),
	  .rx2		(rc_rx2),
	  .rx3		(rc_rx3),
	  .rx4		(rc_rx4),
	  .rx5		(rc_rx5),
	  .rx6		(rc_rx6),
	  .rx7		(rc_rx7),
	  .rx8		(rc_rx8),
	  .rx9		(rc_rx9),
	  .rx10		(rc_rx10),
	  .rx11		(rc_rx11),
	  .rx12		(rc_rx12),
	  .rx13		(rc_rx13),
	  .rx14		(rc_rx14),
	  .rx15		(rc_rx15),
	  .rx16		(rc_rx16),
	  .rx17		(rc_rx17),
	  .rx18		(rc_rx18),
	  .rx19		(rc_rx19),
	  .rx20		(rc_rx20),
	  .rx21		(rc_rx21),
	  .rx22		(rc_rx22),
	  .rx23		(rc_rx23),
	  .rx24		(rc_rx24),
	  .rx25		(rc_rx25),
	  .rx26		(rc_rx26),
	  .rx27		(rc_rx27),
	  .rx28		(rc_rx28),
	  .rx29		(rc_rx29),
	  .rx30		(rc_rx30),
	  .rx31		(rc_rx31),

	  .pclk               (sb_up_pclk               ),
    .Rate               (sb_up_Rate               ),
    .Width              (sb_up_Width              ),
    .PCLK_Rate          (sb_up_PCLK_Rate          ),
    .Reset_n            (sb_up_Reset_n            ),
    .PowerDown          (sb_up_PowerDown          ),
    .TxDetectRxLoopback (sb_up_TxDetectRxLoopback ),
    .TxData0            (sb_up_TxData0            ),
    .TxData1            (sb_up_TxData1            ),
    .TxData2            (sb_up_TxData2            ),
    .TxData3            (sb_up_TxData3            ),
    .TxData4            (sb_up_TxData4            ),
    .TxData5            (sb_up_TxData5            ),
    .TxData6            (sb_up_TxData6            ),
    .TxData7            (sb_up_TxData7            ),
    .TxData8            (sb_up_TxData8            ),
    .TxData9            (sb_up_TxData9            ),
    .TxData10           (sb_up_TxData10           ),
    .TxData11           (sb_up_TxData11           ),
    .TxData12           (sb_up_TxData12           ),
    .TxData13           (sb_up_TxData13           ),
    .TxData14           (sb_up_TxData14           ),
    .TxData15           (sb_up_TxData15           ),
    .TxDataK0           (sb_up_TxDataK0           ),
    .TxDataK1           (sb_up_TxDataK1           ),
    .TxDataK2           (sb_up_TxDataK2           ),
    .TxDataK3           (sb_up_TxDataK3           ),
    .TxDataK4           (sb_up_TxDataK4           ),
    .TxDataK5           (sb_up_TxDataK5           ),
    .TxDataK6           (sb_up_TxDataK6           ),
    .TxDataK7           (sb_up_TxDataK7           ),
    .TxDataK8           (sb_up_TxDataK8           ),
    .TxDataK9           (sb_up_TxDataK9           ),
    .TxDataK10          (sb_up_TxDataK10          ),
    .TxDataK11          (sb_up_TxDataK11          ),
    .TxDataK12          (sb_up_TxDataK12          ),
    .TxDataK13          (sb_up_TxDataK13          ),
    .TxDataK14          (sb_up_TxDataK14          ),
    .TxDataK15          (sb_up_TxDataK15          ),
    .TxElecIdle0        (sb_up_TxElecIdle0        ),
    .TxElecIdle1        (sb_up_TxElecIdle1        ),
    .TxElecIdle2        (sb_up_TxElecIdle2        ),
    .TxElecIdle3        (sb_up_TxElecIdle3        ),
    .TxElecIdle4        (sb_up_TxElecIdle4        ),
    .TxElecIdle5        (sb_up_TxElecIdle5        ),
    .TxElecIdle6        (sb_up_TxElecIdle6        ),
    .TxElecIdle7        (sb_up_TxElecIdle7        ),
    .TxElecIdle8        (sb_up_TxElecIdle8        ),
    .TxElecIdle9        (sb_up_TxElecIdle9        ),
    .TxElecIdle10       (sb_up_TxElecIdle10       ),
    .TxElecIdle11       (sb_up_TxElecIdle11       ),
    .TxElecIdle12       (sb_up_TxElecIdle12       ),
    .TxElecIdle13       (sb_up_TxElecIdle13       ),
    .TxElecIdle14       (sb_up_TxElecIdle14       ),
    .TxElecIdle15       (sb_up_TxElecIdle15       ),
    .TxCompliance0      (sb_up_TxCompliance0      ),
    .TxCompliance1      (sb_up_TxCompliance1      ),
    .TxCompliance2      (sb_up_TxCompliance2      ),
    .TxCompliance3      (sb_up_TxCompliance3      ),
    .TxCompliance4      (sb_up_TxCompliance4      ),
    .TxCompliance5      (sb_up_TxCompliance5      ),
    .TxCompliance6      (sb_up_TxCompliance6      ),
    .TxCompliance7      (sb_up_TxCompliance7      ),
    .TxCompliance8      (sb_up_TxCompliance8      ),
    .TxCompliance9      (sb_up_TxCompliance9      ),
    .TxCompliance10     (sb_up_TxCompliance10     ),
    .TxCompliance11     (sb_up_TxCompliance11     ),
    .TxCompliance12     (sb_up_TxCompliance12     ),
    .TxCompliance13     (sb_up_TxCompliance13     ),
    .TxCompliance14     (sb_up_TxCompliance14     ),
    .TxCompliance15     (sb_up_TxCompliance15     ),
    .RxPolarity0        (sb_up_RxPolarity0        ),
    .RxPolarity1        (sb_up_RxPolarity1        ),
    .RxPolarity2        (sb_up_RxPolarity2        ),
    .RxPolarity3        (sb_up_RxPolarity3        ),
    .RxPolarity4        (sb_up_RxPolarity4        ),
    .RxPolarity5        (sb_up_RxPolarity5        ),
    .RxPolarity6        (sb_up_RxPolarity6        ),
    .RxPolarity7        (sb_up_RxPolarity7        ),
    .RxPolarity8        (sb_up_RxPolarity8        ),
    .RxPolarity9        (sb_up_RxPolarity9        ),
    .RxPolarity10       (sb_up_RxPolarity10       ),
    .RxPolarity11       (sb_up_RxPolarity11       ),
    .RxPolarity12       (sb_up_RxPolarity12       ),
    .RxPolarity13       (sb_up_RxPolarity13       ),
    .RxPolarity14       (sb_up_RxPolarity14       ),
    .RxPolarity15       (sb_up_RxPolarity15       ),
    .TxStartBlock0      (sb_up_TxStartBlock0      ),
    .TxStartBlock1      (sb_up_TxStartBlock1      ),
    .TxStartBlock2      (sb_up_TxStartBlock2      ),
    .TxStartBlock3      (sb_up_TxStartBlock3      ),
    .TxStartBlock4      (sb_up_TxStartBlock4      ),
    .TxStartBlock5      (sb_up_TxStartBlock5      ),
    .TxStartBlock6      (sb_up_TxStartBlock6      ),
    .TxStartBlock7      (sb_up_TxStartBlock7      ),
    .TxStartBlock8      (sb_up_TxStartBlock8      ),
    .TxStartBlock9      (sb_up_TxStartBlock9      ),
    .TxStartBlock10     (sb_up_TxStartBlock10     ),
    .TxStartBlock11     (sb_up_TxStartBlock11     ),
    .TxStartBlock12     (sb_up_TxStartBlock12     ),
    .TxStartBlock13     (sb_up_TxStartBlock13     ),
    .TxStartBlock14     (sb_up_TxStartBlock14     ),
    .TxStartBlock15     (sb_up_TxStartBlock15     ),
    .TxDataValid0       (sb_up_TxDataValid0       ),
    .TxDataValid1       (sb_up_TxDataValid1       ),
    .TxDataValid2       (sb_up_TxDataValid2       ),
    .TxDataValid3       (sb_up_TxDataValid3       ),
    .TxDataValid4       (sb_up_TxDataValid4       ),
    .TxDataValid5       (sb_up_TxDataValid5       ),
    .TxDataValid6       (sb_up_TxDataValid6       ),
    .TxDataValid7       (sb_up_TxDataValid7       ),
    .TxDataValid8       (sb_up_TxDataValid8       ),
    .TxDataValid9       (sb_up_TxDataValid9       ),
    .TxDataValid10      (sb_up_TxDataValid10      ),
    .TxDataValid11      (sb_up_TxDataValid11      ),
    .TxDataValid12      (sb_up_TxDataValid12      ),
    .TxDataValid13      (sb_up_TxDataValid13      ),
    .TxDataValid14      (sb_up_TxDataValid14      ),
    .TxDataValid15      (sb_up_TxDataValid15      ),
    .TxSyncHeader0      (sb_up_TxSyncHeader0      ),
    .TxSyncHeader1      (sb_up_TxSyncHeader1      ),
    .TxSyncHeader2      (sb_up_TxSyncHeader2      ),
    .TxSyncHeader3      (sb_up_TxSyncHeader3      ),
    .TxSyncHeader4      (sb_up_TxSyncHeader4      ),
    .TxSyncHeader5      (sb_up_TxSyncHeader5      ),
    .TxSyncHeader6      (sb_up_TxSyncHeader6      ),
    .TxSyncHeader7      (sb_up_TxSyncHeader7      ),
    .TxSyncHeader8      (sb_up_TxSyncHeader8      ),
    .TxSyncHeader9      (sb_up_TxSyncHeader9      ),
    .TxSyncHeader10     (sb_up_TxSyncHeader10     ),
    .TxSyncHeader11     (sb_up_TxSyncHeader11     ),
    .TxSyncHeader12     (sb_up_TxSyncHeader12     ),
    .TxSyncHeader13     (sb_up_TxSyncHeader13     ),
    .TxSyncHeader14     (sb_up_TxSyncHeader14     ),
    .TxSyncHeader15     (sb_up_TxSyncHeader15     ),
	  .TxEQControl0       (),
	  .TxEQControl1       (),
	  .TxEQControl2       (),
	  .TxEQControl3       (),
	  .TxEQControl4       (),
	  .TxEQControl5       (),
	  .TxEQControl6	      (),
	  .TxEQControl7       (),
	  .TxEQControl8       (),
	  .TxEQControl9       (),
	  .TxEQControl10      (),
	  .TxEQControl11      (),
	  .TxEQControl12      (),
	  .TxEQControl13      (),
	  .TxEQControl14      (),
	  .TxEQControl15      (),
	  .FS                 (),
	  .LF                 (),
    .TxDeemph           (sb_up_TxDeemph           ),                            
    .TxMargin           (sb_up_TxMargin           ),                            
    .BlockAlignControl  (), 
    

    .RxData0            (sb_up_RxData0            ),
    .RxData1            (sb_up_RxData1            ),
    .RxData2            (sb_up_RxData2            ),
    .RxData3            (sb_up_RxData3            ),
    .RxData4            (sb_up_RxData4            ),
    .RxData5            (sb_up_RxData5            ),
    .RxData6            (sb_up_RxData6            ),
    .RxData7            (sb_up_RxData7            ),
    .RxData8            (sb_up_RxData8            ),
    .RxData9            (sb_up_RxData9            ),
    .RxData10           (sb_up_RxData10           ),
    .RxData11           (sb_up_RxData11           ),
    .RxData12           (sb_up_RxData12           ),
    .RxData13           (sb_up_RxData13           ),
    .RxData14           (sb_up_RxData14           ),
    .RxData15           (sb_up_RxData15           ),
    .RxDataK0           (sb_up_RxDataK0           ),
    .RxDataK1           (sb_up_RxDataK1           ),
    .RxDataK2           (sb_up_RxDataK2           ),
    .RxDataK3           (sb_up_RxDataK3           ),
    .RxDataK4           (sb_up_RxDataK4           ),
    .RxDataK5           (sb_up_RxDataK5           ),
    .RxDataK6           (sb_up_RxDataK6           ),
    .RxDataK7           (sb_up_RxDataK7           ),
    .RxDataK8           (sb_up_RxDataK8           ),
    .RxDataK9           (sb_up_RxDataK9           ),
    .RxDataK10          (sb_up_RxDataK10          ),
    .RxDataK11          (sb_up_RxDataK11          ),
    .RxDataK12          (sb_up_RxDataK12          ),
    .RxDataK13          (sb_up_RxDataK13          ),
    .RxDataK14          (sb_up_RxDataK14          ),
    .RxDataK15          (sb_up_RxDataK15          ),
    .RxDataValid0       (sb_up_RxDataValid0       ),
    .RxDataValid1       (sb_up_RxDataValid1       ),
    .RxDataValid2       (sb_up_RxDataValid2       ),
    .RxDataValid3       (sb_up_RxDataValid3       ),
    .RxDataValid4       (sb_up_RxDataValid4       ),
    .RxDataValid5       (sb_up_RxDataValid5       ),
    .RxDataValid6       (sb_up_RxDataValid6       ),
    .RxDataValid7       (sb_up_RxDataValid7       ),
    .RxDataValid8       (sb_up_RxDataValid8       ),
    .RxDataValid9       (sb_up_RxDataValid9       ),
    .RxDataValid10      (sb_up_RxDataValid10      ),
    .RxDataValid11      (sb_up_RxDataValid11      ),
    .RxDataValid12      (sb_up_RxDataValid12      ),
    .RxDataValid13      (sb_up_RxDataValid13      ),
    .RxDataValid14      (sb_up_RxDataValid14      ),
    .RxDataValid15      (sb_up_RxDataValid15      ),
    .RxValid0           (sb_up_RxValid0           ),
    .RxValid1           (sb_up_RxValid1           ),
    .RxValid2           (sb_up_RxValid2           ),
    .RxValid3           (sb_up_RxValid3           ),
    .RxValid4           (sb_up_RxValid4           ),
    .RxValid5           (sb_up_RxValid5           ),
    .RxValid6           (sb_up_RxValid6           ),
    .RxValid7           (sb_up_RxValid7           ),
    .RxValid8           (sb_up_RxValid8           ),
    .RxValid9           (sb_up_RxValid9           ),
    .RxValid10          (sb_up_RxValid10          ),
    .RxValid11          (sb_up_RxValid11          ),
    .RxValid12          (sb_up_RxValid12          ),
    .RxValid13          (sb_up_RxValid13          ),
    .RxValid14          (sb_up_RxValid14          ),
    .RxValid15          (sb_up_RxValid15          ),
    .RxElecIdle0        (sb_up_RxElecIdle0        ),
    .RxElecIdle1        (sb_up_RxElecIdle1        ),
    .RxElecIdle2        (sb_up_RxElecIdle2        ),
    .RxElecIdle3        (sb_up_RxElecIdle3        ),
    .RxElecIdle4        (sb_up_RxElecIdle4        ),
    .RxElecIdle5        (sb_up_RxElecIdle5        ),
    .RxElecIdle6        (sb_up_RxElecIdle6        ),
    .RxElecIdle7        (sb_up_RxElecIdle7        ),
    .RxElecIdle8        (sb_up_RxElecIdle8        ),
    .RxElecIdle9        (sb_up_RxElecIdle9        ),
    .RxElecIdle10       (sb_up_RxElecIdle10       ),
    .RxElecIdle11       (sb_up_RxElecIdle11       ),
    .RxElecIdle12       (sb_up_RxElecIdle12       ),
    .RxElecIdle13       (sb_up_RxElecIdle13       ),
    .RxElecIdle14       (sb_up_RxElecIdle14       ),
    .RxElecIdle15       (sb_up_RxElecIdle15       ),
    .RxStatus0          (sb_up_RxStatus0          ),
    .RxStatus1          (sb_up_RxStatus1          ),
    .RxStatus2          (sb_up_RxStatus2          ),
    .RxStatus3          (sb_up_RxStatus3          ),
    .RxStatus4          (sb_up_RxStatus4          ),
    .RxStatus5          (sb_up_RxStatus5          ),
    .RxStatus6          (sb_up_RxStatus6          ),
    .RxStatus7          (sb_up_RxStatus7          ),
    .RxStatus8          (sb_up_RxStatus8          ),
    .RxStatus9          (sb_up_RxStatus9          ),
    .RxStatus10         (sb_up_RxStatus10         ),
    .RxStatus11         (sb_up_RxStatus11         ),
    .RxStatus12         (sb_up_RxStatus12         ),
    .RxStatus13         (sb_up_RxStatus13         ),
    .RxStatus14         (sb_up_RxStatus14         ),
    .RxStatus15         (sb_up_RxStatus15         ),
    .RxStartBlock0      (sb_up_RxStartBlock0      ),
    .RxStartBlock1      (sb_up_RxStartBlock1      ),
    .RxStartBlock2      (sb_up_RxStartBlock2      ),
    .RxStartBlock3      (sb_up_RxStartBlock3      ),
    .RxStartBlock4      (sb_up_RxStartBlock4      ),
    .RxStartBlock5      (sb_up_RxStartBlock5      ),
    .RxStartBlock6      (sb_up_RxStartBlock6      ),
    .RxStartBlock7      (sb_up_RxStartBlock7      ),
    .RxStartBlock8      (sb_up_RxStartBlock8      ),
    .RxStartBlock9      (sb_up_RxStartBlock9      ),
    .RxStartBlock10     (sb_up_RxStartBlock10     ),
    .RxStartBlock11     (sb_up_RxStartBlock11     ),
    .RxStartBlock12     (sb_up_RxStartBlock12     ),
    .RxStartBlock13     (sb_up_RxStartBlock13     ),
    .RxStartBlock14     (sb_up_RxStartBlock14     ),
    .RxStartBlock15     (sb_up_RxStartBlock15     ),
    .RxSyncHeader0      (sb_up_RxSyncHeader0      ),
    .RxSyncHeader1      (sb_up_RxSyncHeader1      ),
    .RxSyncHeader2      (sb_up_RxSyncHeader2      ),
    .RxSyncHeader3      (sb_up_RxSyncHeader3      ),
    .RxSyncHeader4      (sb_up_RxSyncHeader4      ),
    .RxSyncHeader5      (sb_up_RxSyncHeader5      ),
    .RxSyncHeader6      (sb_up_RxSyncHeader6      ),
    .RxSyncHeader7      (sb_up_RxSyncHeader7      ),
    .RxSyncHeader8      (sb_up_RxSyncHeader8      ),
    .RxSyncHeader9      (sb_up_RxSyncHeader9      ),
    .RxSyncHeader10     (sb_up_RxSyncHeader10     ),
    .RxSyncHeader11     (sb_up_RxSyncHeader11     ),
    .RxSyncHeader12     (sb_up_RxSyncHeader12     ),
    .RxSyncHeader13     (sb_up_RxSyncHeader13     ),
    .RxSyncHeader14     (sb_up_RxSyncHeader14     ),
    .RxSyncHeader15     (sb_up_RxSyncHeader15     ),

    .PhyStatus          (sb_up_PhyStatus          ), 	   
    .TxSwing            (sb_up_TxSwing            ), 

`ifdef EX_GEN2
    .current_speed      (rc_speed_gen2            ),
`endif
`ifdef EX_GEN3
    .current_speed_g3   (rc_speed_gen3            ),
`endif

	  .clk		            (rc_clk                   ),
	  .rst		            (rst                      ));
  
  nvs_ex_monitor 
  Monitor(
    .tx0		(rc_tx0),
    .tx1		(rc_tx1),
    .tx2		(rc_tx2),
    .tx3		(rc_tx3),
    .tx4		(rc_tx4),
    .tx5		(rc_tx5),
    .tx6		(rc_tx6),
    .tx7		(rc_tx7),
    .tx8		(rc_tx8),
    .tx9		(rc_tx9),
    .tx10		(rc_tx10),
    .tx11		(rc_tx11),
    .tx12		(rc_tx12),
    .tx13		(rc_tx13),
    .tx14		(rc_tx14),
    .tx15		(rc_tx15),
    .tx16		(rc_tx16),
    .tx17		(rc_tx17),
    .tx18		(rc_tx18),
    .tx19		(rc_tx19),
    .tx20		(rc_tx20),
    .tx21		(rc_tx21),
    .tx22		(rc_tx22),
    .tx23		(rc_tx23),
    .tx24		(rc_tx24),
    .tx25		(rc_tx25),
    .tx26		(rc_tx26),
    .tx27		(rc_tx27),
    .tx28		(rc_tx28),
    .tx29		(rc_tx29),
    .tx30		(rc_tx30),
    .tx31		(rc_tx31),

    .rx0		(rc_rx0),
    .rx1		(rc_rx1),
    .rx2		(rc_rx2),
    .rx3		(rc_rx3),
    .rx4		(rc_rx4),
    .rx5		(rc_rx5),
    .rx6		(rc_rx6),
    .rx7		(rc_rx7),
    .rx8		(rc_rx8),
    .rx9		(rc_rx9),
    .rx10		(rc_rx10),
    .rx11		(rc_rx11),
    .rx12		(rc_rx12),
    .rx13		(rc_rx13),
    .rx14		(rc_rx14),
    .rx15		(rc_rx15),
    .rx16		(rc_rx16),
    .rx17		(rc_rx17),
    .rx18		(rc_rx18),
    .rx19		(rc_rx19),
    .rx20		(rc_rx20),
    .rx21		(rc_rx21),
    .rx22		(rc_rx22),
    .rx23		(rc_rx23),
    .rx24		(rc_rx24),
    .rx25		(rc_rx25),
    .rx26		(rc_rx26),
    .rx27		(rc_rx27),
    .rx28		(rc_rx28),
    .rx29		(rc_rx29),
    .rx30		(rc_rx30),
    .rx31		(rc_rx31),
    
    .Rate               (sb_up_Rate               ),
    .PCLK_Rate          (sb_up_PCLK_Rate          ),
    .Width              (sb_up_Width              ),
    .Reset_n            (sb_up_Reset_n            ),
    .PowerDown          (sb_up_PowerDown          ),
    .TxDetectRxLoopback (sb_up_TxDetectRxLoopback ),
    .TxData0            (sb_up_TxData0            ),
    .TxData1            (sb_up_TxData1            ),
    .TxData2            (sb_up_TxData2            ),
    .TxData3            (sb_up_TxData3            ),
    .TxData4            (sb_up_TxData4            ),
    .TxData5            (sb_up_TxData5            ),
    .TxData6            (sb_up_TxData6            ),
    .TxData7            (sb_up_TxData7            ),
    .TxData8            (sb_up_TxData8            ),
    .TxData9            (sb_up_TxData9            ),
    .TxData10           (sb_up_TxData10           ),
    .TxData11           (sb_up_TxData11           ),
    .TxData12           (sb_up_TxData12           ),
    .TxData13           (sb_up_TxData13           ),
    .TxData14           (sb_up_TxData14           ),
    .TxData15           (sb_up_TxData15           ),
    .TxDataK0           (sb_up_TxDataK0           ),
    .TxDataK1           (sb_up_TxDataK1           ),
    .TxDataK2           (sb_up_TxDataK2           ),
    .TxDataK3           (sb_up_TxDataK3           ),
    .TxDataK4           (sb_up_TxDataK4           ),
    .TxDataK5           (sb_up_TxDataK5           ),
    .TxDataK6           (sb_up_TxDataK6           ),
    .TxDataK7           (sb_up_TxDataK7           ),
    .TxDataK8           (sb_up_TxDataK8           ),
    .TxDataK9           (sb_up_TxDataK9           ),
    .TxDataK10          (sb_up_TxDataK10          ),
    .TxDataK11          (sb_up_TxDataK11          ),
    .TxDataK12          (sb_up_TxDataK12          ),
    .TxDataK13          (sb_up_TxDataK13          ),
    .TxDataK14          (sb_up_TxDataK14          ),
    .TxDataK15          (sb_up_TxDataK15          ),
    .TxDataValid0       (sb_up_TxDataValid0       ),
    .TxDataValid1       (sb_up_TxDataValid1       ),
    .TxDataValid2       (sb_up_TxDataValid2       ),
    .TxDataValid3       (sb_up_TxDataValid3       ),
    .TxDataValid4       (sb_up_TxDataValid4       ),
    .TxDataValid5       (sb_up_TxDataValid5       ),
    .TxDataValid6       (sb_up_TxDataValid6       ),
    .TxDataValid7       (sb_up_TxDataValid7       ),
    .TxDataValid8       (sb_up_TxDataValid8       ),
    .TxDataValid9       (sb_up_TxDataValid9       ),
    .TxDataValid10      (sb_up_TxDataValid10      ),
    .TxDataValid11      (sb_up_TxDataValid11      ),
    .TxDataValid12      (sb_up_TxDataValid12      ),
    .TxDataValid13      (sb_up_TxDataValid13      ),
    .TxDataValid14      (sb_up_TxDataValid14      ),
    .TxDataValid15      (sb_up_TxDataValid15      ),
    .TxElecIdle0        (sb_up_TxElecIdle0        ),
    .TxElecIdle1        (sb_up_TxElecIdle1        ),
    .TxElecIdle2        (sb_up_TxElecIdle2        ),
    .TxElecIdle3        (sb_up_TxElecIdle3        ),
    .TxElecIdle4        (sb_up_TxElecIdle4        ),
    .TxElecIdle5        (sb_up_TxElecIdle5        ),
    .TxElecIdle6        (sb_up_TxElecIdle6        ),
    .TxElecIdle7        (sb_up_TxElecIdle7        ),
    .TxElecIdle8        (sb_up_TxElecIdle8        ),
    .TxElecIdle9        (sb_up_TxElecIdle9        ),
    .TxElecIdle10       (sb_up_TxElecIdle10       ),
    .TxElecIdle11       (sb_up_TxElecIdle11       ),
    .TxElecIdle12       (sb_up_TxElecIdle12       ),
    .TxElecIdle13       (sb_up_TxElecIdle13       ),
    .TxElecIdle14       (sb_up_TxElecIdle14       ),
    .TxElecIdle15       (sb_up_TxElecIdle15       ),
    .TxCompliance0      (sb_up_TxCompliance0      ),
    .TxCompliance1      (sb_up_TxCompliance1      ),
    .TxCompliance2      (sb_up_TxCompliance2      ),
    .TxCompliance3      (sb_up_TxCompliance3      ),
    .TxCompliance4      (sb_up_TxCompliance4      ),
    .TxCompliance5      (sb_up_TxCompliance5      ),
    .TxCompliance6      (sb_up_TxCompliance6      ),
    .TxCompliance7      (sb_up_TxCompliance7      ),
    .TxCompliance8      (sb_up_TxCompliance8      ),
    .TxCompliance9      (sb_up_TxCompliance9      ),
    .TxCompliance10     (sb_up_TxCompliance10     ),
    .TxCompliance11     (sb_up_TxCompliance11     ),
    .TxCompliance12     (sb_up_TxCompliance12     ),
    .TxCompliance13     (sb_up_TxCompliance13     ),
    .TxCompliance14     (sb_up_TxCompliance14     ),
    .TxCompliance15     (sb_up_TxCompliance15     ),
    .RxPolarity0        (sb_up_RxPolarity0        ),
    .RxPolarity1        (sb_up_RxPolarity1        ),
    .RxPolarity2        (sb_up_RxPolarity2        ),
    .RxPolarity3        (sb_up_RxPolarity3        ),
    .RxPolarity4        (sb_up_RxPolarity4        ),
    .RxPolarity5        (sb_up_RxPolarity5        ),
    .RxPolarity6        (sb_up_RxPolarity6        ),
    .RxPolarity7        (sb_up_RxPolarity7        ),
    .RxPolarity8        (sb_up_RxPolarity8        ),
    .RxPolarity9        (sb_up_RxPolarity9        ),
    .RxPolarity10       (sb_up_RxPolarity10       ),
    .RxPolarity11       (sb_up_RxPolarity11       ),
    .RxPolarity12       (sb_up_RxPolarity12       ),
    .RxPolarity13       (sb_up_RxPolarity13       ),
    .RxPolarity14       (sb_up_RxPolarity14       ),
    .RxPolarity15       (sb_up_RxPolarity15       ),
    .TxStartBlock0      (sb_up_TxStartBlock0      ),
    .TxStartBlock1      (sb_up_TxStartBlock1      ),
    .TxStartBlock2      (sb_up_TxStartBlock2      ),
    .TxStartBlock3      (sb_up_TxStartBlock3      ),
    .TxStartBlock4      (sb_up_TxStartBlock4      ),
    .TxStartBlock5      (sb_up_TxStartBlock5      ),
    .TxStartBlock6      (sb_up_TxStartBlock6      ),
    .TxStartBlock7      (sb_up_TxStartBlock7      ),
    .TxStartBlock8      (sb_up_TxStartBlock8      ),
    .TxStartBlock9      (sb_up_TxStartBlock9      ),
    .TxStartBlock10     (sb_up_TxStartBlock10     ),
    .TxStartBlock11     (sb_up_TxStartBlock11     ),
    .TxStartBlock12     (sb_up_TxStartBlock12     ),
    .TxStartBlock13     (sb_up_TxStartBlock13     ),
    .TxStartBlock14     (sb_up_TxStartBlock14     ),
    .TxStartBlock15     (sb_up_TxStartBlock15     ),
    .TxSyncHeader0      (sb_up_TxSyncHeader0      ),
    .TxSyncHeader1      (sb_up_TxSyncHeader1      ),
    .TxSyncHeader2      (sb_up_TxSyncHeader2      ),
    .TxSyncHeader3      (sb_up_TxSyncHeader3      ),
    .TxSyncHeader4      (sb_up_TxSyncHeader4      ),
    .TxSyncHeader5      (sb_up_TxSyncHeader5      ),
    .TxSyncHeader6      (sb_up_TxSyncHeader6      ),
    .TxSyncHeader7      (sb_up_TxSyncHeader7      ),
    .TxSyncHeader8      (sb_up_TxSyncHeader8      ),
    .TxSyncHeader9      (sb_up_TxSyncHeader9      ),
    .TxSyncHeader10     (sb_up_TxSyncHeader10     ),
    .TxSyncHeader11     (sb_up_TxSyncHeader11     ),
    .TxSyncHeader12     (sb_up_TxSyncHeader12     ),
    .TxSyncHeader13     (sb_up_TxSyncHeader13     ),
    .TxSyncHeader14     (sb_up_TxSyncHeader14     ),
    .TxSyncHeader15     (sb_up_TxSyncHeader15     ),
    .TxMargin           (sb_up_TxMargin           ),                            
    .TxDeemph           (sb_up_TxDeemph           ),                            

    .RxData0            (sb_up_RxData0            ),
    .RxData1            (sb_up_RxData1            ),
    .RxData2            (sb_up_RxData2            ),
    .RxData3            (sb_up_RxData3            ),
    .RxData4            (sb_up_RxData4            ),
    .RxData5            (sb_up_RxData5            ),
    .RxData6            (sb_up_RxData6            ),
    .RxData7            (sb_up_RxData7            ),
    .RxData8            (sb_up_RxData8            ),
    .RxData9            (sb_up_RxData9            ),
    .RxData10           (sb_up_RxData10           ),
    .RxData11           (sb_up_RxData11           ),
    .RxData12           (sb_up_RxData12           ),
    .RxData13           (sb_up_RxData13           ),
    .RxData14           (sb_up_RxData14           ),
    .RxData15           (sb_up_RxData15           ),
    .RxDataK0           (sb_up_RxDataK0           ),
    .RxDataK1           (sb_up_RxDataK1           ),
    .RxDataK2           (sb_up_RxDataK2           ),
    .RxDataK3           (sb_up_RxDataK3           ),
    .RxDataK4           (sb_up_RxDataK4           ),
    .RxDataK5           (sb_up_RxDataK5           ),
    .RxDataK6           (sb_up_RxDataK6           ),
    .RxDataK7           (sb_up_RxDataK7           ),
    .RxDataK8           (sb_up_RxDataK8           ),
    .RxDataK9           (sb_up_RxDataK9           ),
    .RxDataK10          (sb_up_RxDataK10          ),
    .RxDataK11          (sb_up_RxDataK11          ),
    .RxDataK12          (sb_up_RxDataK12          ),
    .RxDataK13          (sb_up_RxDataK13          ),
    .RxDataK14          (sb_up_RxDataK14          ),
    .RxDataK15          (sb_up_RxDataK15          ),
    .RxDataValid0       (sb_up_RxDataValid0       ),
    .RxDataValid1       (sb_up_RxDataValid1       ),
    .RxDataValid2       (sb_up_RxDataValid2       ),
    .RxDataValid3       (sb_up_RxDataValid3       ),
    .RxDataValid4       (sb_up_RxDataValid4       ),
    .RxDataValid5       (sb_up_RxDataValid5       ),
    .RxDataValid6       (sb_up_RxDataValid6       ),
    .RxDataValid7       (sb_up_RxDataValid7       ),
    .RxDataValid8       (sb_up_RxDataValid8       ),
    .RxDataValid9       (sb_up_RxDataValid9       ),
    .RxDataValid10      (sb_up_RxDataValid10      ),
    .RxDataValid11      (sb_up_RxDataValid11      ),
    .RxDataValid12      (sb_up_RxDataValid12      ),
    .RxDataValid13      (sb_up_RxDataValid13      ),
    .RxDataValid14      (sb_up_RxDataValid14      ),
    .RxDataValid15      (sb_up_RxDataValid15      ),
    .RxValid0           (sb_up_RxValid0           ),
    .RxValid1           (sb_up_RxValid1           ),
    .RxValid2           (sb_up_RxValid2           ),
    .RxValid3           (sb_up_RxValid3           ),
    .RxValid4           (sb_up_RxValid4           ),
    .RxValid5           (sb_up_RxValid5           ),
    .RxValid6           (sb_up_RxValid6           ),
    .RxValid7           (sb_up_RxValid7           ),
    .RxValid8           (sb_up_RxValid8           ),
    .RxValid9           (sb_up_RxValid9           ),
    .RxValid10          (sb_up_RxValid10          ),
    .RxValid11          (sb_up_RxValid11          ),
    .RxValid12          (sb_up_RxValid12          ),
    .RxValid13          (sb_up_RxValid13          ),
    .RxValid14          (sb_up_RxValid14          ),
    .RxValid15          (sb_up_RxValid15          ),
    .RxElecIdle0        (sb_up_RxElecIdle0        ),
    .RxElecIdle1        (sb_up_RxElecIdle1        ),
    .RxElecIdle2        (sb_up_RxElecIdle2        ),
    .RxElecIdle3        (sb_up_RxElecIdle3        ),
    .RxElecIdle4        (sb_up_RxElecIdle4        ),
    .RxElecIdle5        (sb_up_RxElecIdle5        ),
    .RxElecIdle6        (sb_up_RxElecIdle6        ),
    .RxElecIdle7        (sb_up_RxElecIdle7        ),
    .RxElecIdle8        (sb_up_RxElecIdle8        ),
    .RxElecIdle9        (sb_up_RxElecIdle9        ),
    .RxElecIdle10       (sb_up_RxElecIdle10       ),
    .RxElecIdle11       (sb_up_RxElecIdle11       ),
    .RxElecIdle12       (sb_up_RxElecIdle12       ),
    .RxElecIdle13       (sb_up_RxElecIdle13       ),
    .RxElecIdle14       (sb_up_RxElecIdle14       ),
    .RxElecIdle15       (sb_up_RxElecIdle15       ),
    .RxStatus0          (sb_up_RxStatus0          ),
    .RxStatus1          (sb_up_RxStatus1          ),
    .RxStatus2          (sb_up_RxStatus2          ),
    .RxStatus3          (sb_up_RxStatus3          ),
    .RxStatus4          (sb_up_RxStatus4          ),
    .RxStatus5          (sb_up_RxStatus5          ),
    .RxStatus6          (sb_up_RxStatus6          ),
    .RxStatus7          (sb_up_RxStatus7          ),
    .RxStatus8          (sb_up_RxStatus8          ),
    .RxStatus9          (sb_up_RxStatus9          ),
    .RxStatus10         (sb_up_RxStatus10         ),
    .RxStatus11         (sb_up_RxStatus11         ),
    .RxStatus12         (sb_up_RxStatus12         ),
    .RxStatus13         (sb_up_RxStatus13         ),
    .RxStatus14         (sb_up_RxStatus14         ),
    .RxStatus15         (sb_up_RxStatus15         ),
    .RxStartBlock0      (sb_up_RxStartBlock0      ),
    .RxStartBlock1      (sb_up_RxStartBlock1      ),
    .RxStartBlock2      (sb_up_RxStartBlock2      ),
    .RxStartBlock3      (sb_up_RxStartBlock3      ),
    .RxStartBlock4      (sb_up_RxStartBlock4      ),
    .RxStartBlock5      (sb_up_RxStartBlock5      ),
    .RxStartBlock6      (sb_up_RxStartBlock6      ),
    .RxStartBlock7      (sb_up_RxStartBlock7      ),
    .RxStartBlock8      (sb_up_RxStartBlock8      ),
    .RxStartBlock9      (sb_up_RxStartBlock9      ),
    .RxStartBlock10     (sb_up_RxStartBlock10     ),
    .RxStartBlock11     (sb_up_RxStartBlock11     ),
    .RxStartBlock12     (sb_up_RxStartBlock12     ),
    .RxStartBlock13     (sb_up_RxStartBlock13     ),
    .RxStartBlock14     (sb_up_RxStartBlock14     ),
    .RxStartBlock15     (sb_up_RxStartBlock15     ),
    .RxSyncHeader0      (sb_up_RxSyncHeader0      ),
    .RxSyncHeader1      (sb_up_RxSyncHeader1      ),
    .RxSyncHeader2      (sb_up_RxSyncHeader2      ),
    .RxSyncHeader3      (sb_up_RxSyncHeader3      ),
    .RxSyncHeader4      (sb_up_RxSyncHeader4      ),
    .RxSyncHeader5      (sb_up_RxSyncHeader5      ),
    .RxSyncHeader6      (sb_up_RxSyncHeader6      ),
    .RxSyncHeader7      (sb_up_RxSyncHeader7      ),
    .RxSyncHeader8      (sb_up_RxSyncHeader8      ),
    .RxSyncHeader9      (sb_up_RxSyncHeader9      ),
    .RxSyncHeader10     (sb_up_RxSyncHeader10     ),
    .RxSyncHeader11     (sb_up_RxSyncHeader11     ),
    .RxSyncHeader12     (sb_up_RxSyncHeader12     ),
    .RxSyncHeader13     (sb_up_RxSyncHeader13     ),
    .RxSyncHeader14     (sb_up_RxSyncHeader14     ),
    .RxSyncHeader15     (sb_up_RxSyncHeader15     ),
    .TxSwing            (sb_up_TxSwing            ), 

`ifdef EX_GEN2
    .current_speed      (rc_speed_gen2            ),
`endif
`ifdef EX_GEN3
    .current_speed_g3   (rc_speed_gen3            ),
`endif

    .clk		            (rc_clk                   ),
    .pclk               (sb_up_pclk               ),
    .rst		            (rst                      ));

  nvs_ex_check
  Checker( 
    .tx0		(rc_tx0),
    .tx1		(rc_tx1),
    .tx2		(rc_tx2),
    .tx3		(rc_tx3),
    .tx4		(rc_tx4),
    .tx5		(rc_tx5),
    .tx6		(rc_tx6),
    .tx7		(rc_tx7),
    .tx8		(rc_tx8),
    .tx9		(rc_tx9),
    .tx10		(rc_tx10),
    .tx11		(rc_tx11),
    .tx12		(rc_tx12),
    .tx13		(rc_tx13),
    .tx14		(rc_tx14),
    .tx15		(rc_tx15),
    .tx16		(rc_tx16),
    .tx17		(rc_tx17),
    .tx18		(rc_tx18),
    .tx19		(rc_tx19),
    .tx20		(rc_tx20),
    .tx21		(rc_tx21),
    .tx22		(rc_tx22),
    .tx23		(rc_tx23),
    .tx24		(rc_tx24),
    .tx25		(rc_tx25),
    .tx26		(rc_tx26),
    .tx27		(rc_tx27),
    .tx28		(rc_tx28),
    .tx29		(rc_tx29),
    .tx30		(rc_tx30),
    .tx31		(rc_tx31),

    .rx0		(rc_rx0),
    .rx1		(rc_rx1),
    .rx2		(rc_rx2),
    .rx3		(rc_rx3),
    .rx4		(rc_rx4),
    .rx5		(rc_rx5),
    .rx6		(rc_rx6),
    .rx7		(rc_rx7),
    .rx8		(rc_rx8),
    .rx9		(rc_rx9),
    .rx10		(rc_rx10),
    .rx11		(rc_rx11),
    .rx12		(rc_rx12),
    .rx13		(rc_rx13),
    .rx14		(rc_rx14),
    .rx15		(rc_rx15),
    .rx16		(rc_rx16),
    .rx17		(rc_rx17),
    .rx18		(rc_rx18),
    .rx19		(rc_rx19),
    .rx20		(rc_rx20),
    .rx21		(rc_rx21),
    .rx22		(rc_rx22),
    .rx23		(rc_rx23),
    .rx24		(rc_rx24),
    .rx25		(rc_rx25),
    .rx26		(rc_rx26),
    .rx27		(rc_rx27),
    .rx28		(rc_rx28),
    .rx29		(rc_rx29),
    .rx30		(rc_rx30),
    .rx31		(rc_rx31),

    .Rate               (sb_up_Rate               ),
    .PCLK_Rate          (sb_up_PCLK_Rate          ),
    .Width              (sb_up_Width              ),
    .Reset_n            (sb_up_Reset_n            ),
    .PowerDown          (sb_up_PowerDown          ),
    .TxDetectRxLoopback (sb_up_TxDetectRxLoopback ),
    .TxData0            (sb_up_TxData0            ),
    .TxData1            (sb_up_TxData1            ),
    .TxData2            (sb_up_TxData2            ),
    .TxData3            (sb_up_TxData3            ),
    .TxData4            (sb_up_TxData4            ),
    .TxData5            (sb_up_TxData5            ),
    .TxData6            (sb_up_TxData6            ),
    .TxData7            (sb_up_TxData7            ),
    .TxData8            (sb_up_TxData8            ),
    .TxData9            (sb_up_TxData9            ),
    .TxData10           (sb_up_TxData10           ),
    .TxData11           (sb_up_TxData11           ),
    .TxData12           (sb_up_TxData12           ),
    .TxData13           (sb_up_TxData13           ),
    .TxData14           (sb_up_TxData14           ),
    .TxData15           (sb_up_TxData15           ),
    .TxDataK0           (sb_up_TxDataK0           ),
    .TxDataK1           (sb_up_TxDataK1           ),
    .TxDataK2           (sb_up_TxDataK2           ),
    .TxDataK3           (sb_up_TxDataK3           ),
    .TxDataK4           (sb_up_TxDataK4           ),
    .TxDataK5           (sb_up_TxDataK5           ),
    .TxDataK6           (sb_up_TxDataK6           ),
    .TxDataK7           (sb_up_TxDataK7           ),
    .TxDataK8           (sb_up_TxDataK8           ),
    .TxDataK9           (sb_up_TxDataK9           ),
    .TxDataK10          (sb_up_TxDataK10          ),
    .TxDataK11          (sb_up_TxDataK11          ),
    .TxDataK12          (sb_up_TxDataK12          ),
    .TxDataK13          (sb_up_TxDataK13          ),
    .TxDataK14          (sb_up_TxDataK14          ),
    .TxDataK15          (sb_up_TxDataK15          ),
    .TxDataValid0       (sb_up_TxDataValid0       ),
    .TxDataValid1       (sb_up_TxDataValid1       ),
    .TxDataValid2       (sb_up_TxDataValid2       ),
    .TxDataValid3       (sb_up_TxDataValid3       ),
    .TxDataValid4       (sb_up_TxDataValid4       ),
    .TxDataValid5       (sb_up_TxDataValid5       ),
    .TxDataValid6       (sb_up_TxDataValid6       ),
    .TxDataValid7       (sb_up_TxDataValid7       ),
    .TxDataValid8       (sb_up_TxDataValid8       ),
    .TxDataValid9       (sb_up_TxDataValid9       ),
    .TxDataValid10      (sb_up_TxDataValid10      ),
    .TxDataValid11      (sb_up_TxDataValid11      ),
    .TxDataValid12      (sb_up_TxDataValid12      ),
    .TxDataValid13      (sb_up_TxDataValid13      ),
    .TxDataValid14      (sb_up_TxDataValid14      ),
    .TxDataValid15      (sb_up_TxDataValid15      ),
    .TxElecIdle0        (sb_up_TxElecIdle0        ),
    .TxElecIdle1        (sb_up_TxElecIdle1        ),
    .TxElecIdle2        (sb_up_TxElecIdle2        ),
    .TxElecIdle3        (sb_up_TxElecIdle3        ),
    .TxElecIdle4        (sb_up_TxElecIdle4        ),
    .TxElecIdle5        (sb_up_TxElecIdle5        ),
    .TxElecIdle6        (sb_up_TxElecIdle6        ),
    .TxElecIdle7        (sb_up_TxElecIdle7        ),
    .TxElecIdle8        (sb_up_TxElecIdle8        ),
    .TxElecIdle9        (sb_up_TxElecIdle9        ),
    .TxElecIdle10       (sb_up_TxElecIdle10       ),
    .TxElecIdle11       (sb_up_TxElecIdle11       ),
    .TxElecIdle12       (sb_up_TxElecIdle12       ),
    .TxElecIdle13       (sb_up_TxElecIdle13       ),
    .TxElecIdle14       (sb_up_TxElecIdle14       ),
    .TxElecIdle15       (sb_up_TxElecIdle15       ),
    .TxCompliance0      (sb_up_TxCompliance0      ),
    .TxCompliance1      (sb_up_TxCompliance1      ),
    .TxCompliance2      (sb_up_TxCompliance2      ),
    .TxCompliance3      (sb_up_TxCompliance3      ),
    .TxCompliance4      (sb_up_TxCompliance4      ),
    .TxCompliance5      (sb_up_TxCompliance5      ),
    .TxCompliance6      (sb_up_TxCompliance6      ),
    .TxCompliance7      (sb_up_TxCompliance7      ),
    .TxCompliance8      (sb_up_TxCompliance8      ),
    .TxCompliance9      (sb_up_TxCompliance9      ),
    .TxCompliance10     (sb_up_TxCompliance10     ),
    .TxCompliance11     (sb_up_TxCompliance11     ),
    .TxCompliance12     (sb_up_TxCompliance12     ),
    .TxCompliance13     (sb_up_TxCompliance13     ),
    .TxCompliance14     (sb_up_TxCompliance14     ),
    .TxCompliance15     (sb_up_TxCompliance15     ),
    .RxPolarity0        (sb_up_RxPolarity0        ),
    .RxPolarity1        (sb_up_RxPolarity1        ),
    .RxPolarity2        (sb_up_RxPolarity2        ),
    .RxPolarity3        (sb_up_RxPolarity3        ),
    .RxPolarity4        (sb_up_RxPolarity4        ),
    .RxPolarity5        (sb_up_RxPolarity5        ),
    .RxPolarity6        (sb_up_RxPolarity6        ),
    .RxPolarity7        (sb_up_RxPolarity7        ),
    .RxPolarity8        (sb_up_RxPolarity8        ),
    .RxPolarity9        (sb_up_RxPolarity9        ),
    .RxPolarity10       (sb_up_RxPolarity10       ),
    .RxPolarity11       (sb_up_RxPolarity11       ),
    .RxPolarity12       (sb_up_RxPolarity12       ),
    .RxPolarity13       (sb_up_RxPolarity13       ),
    .RxPolarity14       (sb_up_RxPolarity14       ),
    .RxPolarity15       (sb_up_RxPolarity15       ),
    .TxStartBlock0      (sb_up_TxStartBlock0      ),
    .TxStartBlock1      (sb_up_TxStartBlock1      ),
    .TxStartBlock2      (sb_up_TxStartBlock2      ),
    .TxStartBlock3      (sb_up_TxStartBlock3      ),
    .TxStartBlock4      (sb_up_TxStartBlock4      ),
    .TxStartBlock5      (sb_up_TxStartBlock5      ),
    .TxStartBlock6      (sb_up_TxStartBlock6      ),
    .TxStartBlock7      (sb_up_TxStartBlock7      ),
    .TxStartBlock8      (sb_up_TxStartBlock8      ),
    .TxStartBlock9      (sb_up_TxStartBlock9      ),
    .TxStartBlock10     (sb_up_TxStartBlock10     ),
    .TxStartBlock11     (sb_up_TxStartBlock11     ),
    .TxStartBlock12     (sb_up_TxStartBlock12     ),
    .TxStartBlock13     (sb_up_TxStartBlock13     ),
    .TxStartBlock14     (sb_up_TxStartBlock14     ),
    .TxStartBlock15     (sb_up_TxStartBlock15     ),
    .TxSyncHeader0      (sb_up_TxSyncHeader0      ),
    .TxSyncHeader1      (sb_up_TxSyncHeader1      ),
    .TxSyncHeader2      (sb_up_TxSyncHeader2      ),
    .TxSyncHeader3      (sb_up_TxSyncHeader3      ),
    .TxSyncHeader4      (sb_up_TxSyncHeader4      ),
    .TxSyncHeader5      (sb_up_TxSyncHeader5      ),
    .TxSyncHeader6      (sb_up_TxSyncHeader6      ),
    .TxSyncHeader7      (sb_up_TxSyncHeader7      ),
    .TxSyncHeader8      (sb_up_TxSyncHeader8      ),
    .TxSyncHeader9      (sb_up_TxSyncHeader9      ),
    .TxSyncHeader10     (sb_up_TxSyncHeader10     ),
    .TxSyncHeader11     (sb_up_TxSyncHeader11     ),
    .TxSyncHeader12     (sb_up_TxSyncHeader12     ),
    .TxSyncHeader13     (sb_up_TxSyncHeader13     ),
    .TxSyncHeader14     (sb_up_TxSyncHeader14     ),
    .TxSyncHeader15     (sb_up_TxSyncHeader15     ),
    .TxMargin           (sb_up_TxMargin           ),                            
    .TxDeemph           (sb_up_TxDeemph           ),                            

    .RxData0            (sb_up_RxData0            ),
    .RxData1            (sb_up_RxData1            ),
    .RxData2            (sb_up_RxData2            ),
    .RxData3            (sb_up_RxData3            ),
    .RxData4            (sb_up_RxData4            ),
    .RxData5            (sb_up_RxData5            ),
    .RxData6            (sb_up_RxData6            ),
    .RxData7            (sb_up_RxData7            ),
    .RxData8            (sb_up_RxData8            ),
    .RxData9            (sb_up_RxData9            ),
    .RxData10           (sb_up_RxData10           ),
    .RxData11           (sb_up_RxData11           ),
    .RxData12           (sb_up_RxData12           ),
    .RxData13           (sb_up_RxData13           ),
    .RxData14           (sb_up_RxData14           ),
    .RxData15           (sb_up_RxData15           ),
    .RxDataK0           (sb_up_RxDataK0           ),
    .RxDataK1           (sb_up_RxDataK1           ),
    .RxDataK2           (sb_up_RxDataK2           ),
    .RxDataK3           (sb_up_RxDataK3           ),
    .RxDataK4           (sb_up_RxDataK4           ),
    .RxDataK5           (sb_up_RxDataK5           ),
    .RxDataK6           (sb_up_RxDataK6           ),
    .RxDataK7           (sb_up_RxDataK7           ),
    .RxDataK8           (sb_up_RxDataK8           ),
    .RxDataK9           (sb_up_RxDataK9           ),
    .RxDataK10          (sb_up_RxDataK10          ),
    .RxDataK11          (sb_up_RxDataK11          ),
    .RxDataK12          (sb_up_RxDataK12          ),
    .RxDataK13          (sb_up_RxDataK13          ),
    .RxDataK14          (sb_up_RxDataK14          ),
    .RxDataK15          (sb_up_RxDataK15          ),
    .RxDataValid0       (sb_up_RxDataValid0       ),
    .RxDataValid1       (sb_up_RxDataValid1       ),
    .RxDataValid2       (sb_up_RxDataValid2       ),
    .RxDataValid3       (sb_up_RxDataValid3       ),
    .RxDataValid4       (sb_up_RxDataValid4       ),
    .RxDataValid5       (sb_up_RxDataValid5       ),
    .RxDataValid6       (sb_up_RxDataValid6       ),
    .RxDataValid7       (sb_up_RxDataValid7       ),
    .RxDataValid8       (sb_up_RxDataValid8       ),
    .RxDataValid9       (sb_up_RxDataValid9       ),
    .RxDataValid10      (sb_up_RxDataValid10      ),
    .RxDataValid11      (sb_up_RxDataValid11      ),
    .RxDataValid12      (sb_up_RxDataValid12      ),
    .RxDataValid13      (sb_up_RxDataValid13      ),
    .RxDataValid14      (sb_up_RxDataValid14      ),
    .RxDataValid15      (sb_up_RxDataValid15      ),
    .RxValid0           (sb_up_RxValid0           ),
    .RxValid1           (sb_up_RxValid1           ),
    .RxValid2           (sb_up_RxValid2           ),
    .RxValid3           (sb_up_RxValid3           ),
    .RxValid4           (sb_up_RxValid4           ),
    .RxValid5           (sb_up_RxValid5           ),
    .RxValid6           (sb_up_RxValid6           ),
    .RxValid7           (sb_up_RxValid7           ),
    .RxValid8           (sb_up_RxValid8           ),
    .RxValid9           (sb_up_RxValid9           ),
    .RxValid10          (sb_up_RxValid10          ),
    .RxValid11          (sb_up_RxValid11          ),
    .RxValid12          (sb_up_RxValid12          ),
    .RxValid13          (sb_up_RxValid13          ),
    .RxValid14          (sb_up_RxValid14          ),
    .RxValid15          (sb_up_RxValid15          ),
    .RxElecIdle0        (sb_up_RxElecIdle0        ),
    .RxElecIdle1        (sb_up_RxElecIdle1        ),
    .RxElecIdle2        (sb_up_RxElecIdle2        ),
    .RxElecIdle3        (sb_up_RxElecIdle3        ),
    .RxElecIdle4        (sb_up_RxElecIdle4        ),
    .RxElecIdle5        (sb_up_RxElecIdle5        ),
    .RxElecIdle6        (sb_up_RxElecIdle6        ),
    .RxElecIdle7        (sb_up_RxElecIdle7        ),
    .RxElecIdle8        (sb_up_RxElecIdle8        ),
    .RxElecIdle9        (sb_up_RxElecIdle9        ),
    .RxElecIdle10       (sb_up_RxElecIdle10       ),
    .RxElecIdle11       (sb_up_RxElecIdle11       ),
    .RxElecIdle12       (sb_up_RxElecIdle12       ),
    .RxElecIdle13       (sb_up_RxElecIdle13       ),
    .RxElecIdle14       (sb_up_RxElecIdle14       ),
    .RxElecIdle15       (sb_up_RxElecIdle15       ),
    .RxStatus0          (sb_up_RxStatus0          ),
    .RxStatus1          (sb_up_RxStatus1          ),
    .RxStatus2          (sb_up_RxStatus2          ),
    .RxStatus3          (sb_up_RxStatus3          ),
    .RxStatus4          (sb_up_RxStatus4          ),
    .RxStatus5          (sb_up_RxStatus5          ),
    .RxStatus6          (sb_up_RxStatus6          ),
    .RxStatus7          (sb_up_RxStatus7          ),
    .RxStatus8          (sb_up_RxStatus8          ),
    .RxStatus9          (sb_up_RxStatus9          ),
    .RxStatus10         (sb_up_RxStatus10         ),
    .RxStatus11         (sb_up_RxStatus11         ),
    .RxStatus12         (sb_up_RxStatus12         ),
    .RxStatus13         (sb_up_RxStatus13         ),
    .RxStatus14         (sb_up_RxStatus14         ),
    .RxStatus15         (sb_up_RxStatus15         ),
    .RxStartBlock0      (sb_up_RxStartBlock0      ),
    .RxStartBlock1      (sb_up_RxStartBlock1      ),
    .RxStartBlock2      (sb_up_RxStartBlock2      ),
    .RxStartBlock3      (sb_up_RxStartBlock3      ),
    .RxStartBlock4      (sb_up_RxStartBlock4      ),
    .RxStartBlock5      (sb_up_RxStartBlock5      ),
    .RxStartBlock6      (sb_up_RxStartBlock6      ),
    .RxStartBlock7      (sb_up_RxStartBlock7      ),
    .RxStartBlock8      (sb_up_RxStartBlock8      ),
    .RxStartBlock9      (sb_up_RxStartBlock9      ),
    .RxStartBlock10     (sb_up_RxStartBlock10     ),
    .RxStartBlock11     (sb_up_RxStartBlock11     ),
    .RxStartBlock12     (sb_up_RxStartBlock12     ),
    .RxStartBlock13     (sb_up_RxStartBlock13     ),
    .RxStartBlock14     (sb_up_RxStartBlock14     ),
    .RxStartBlock15     (sb_up_RxStartBlock15     ),
    .RxSyncHeader0      (sb_up_RxSyncHeader0      ),
    .RxSyncHeader1      (sb_up_RxSyncHeader1      ),
    .RxSyncHeader2      (sb_up_RxSyncHeader2      ),
    .RxSyncHeader3      (sb_up_RxSyncHeader3      ),
    .RxSyncHeader4      (sb_up_RxSyncHeader4      ),
    .RxSyncHeader5      (sb_up_RxSyncHeader5      ),
    .RxSyncHeader6      (sb_up_RxSyncHeader6      ),
    .RxSyncHeader7      (sb_up_RxSyncHeader7      ),
    .RxSyncHeader8      (sb_up_RxSyncHeader8      ),
    .RxSyncHeader9      (sb_up_RxSyncHeader9      ),
    .RxSyncHeader10     (sb_up_RxSyncHeader10     ),
    .RxSyncHeader11     (sb_up_RxSyncHeader11     ),
    .RxSyncHeader12     (sb_up_RxSyncHeader12     ),
    .RxSyncHeader13     (sb_up_RxSyncHeader13     ),
    .RxSyncHeader14     (sb_up_RxSyncHeader14     ),
    .RxSyncHeader15     (sb_up_RxSyncHeader15     ),
    .TxSwing            (sb_up_TxSwing            ), 
    
`ifdef EX_GEN2
    .current_speed      (rc_speed_gen2            ),
`endif
`ifdef EX_GEN3
    .current_speed_g3   (rc_speed_gen3            ),
`endif

    .clk		            (rc_clk                   ),
    .pclk               (sb_up_pclk               ),
    .rst		            (rst                      )); 

`ifdef SB_UPLINK_IS_PIPE
`ifdef SB_UPLINK_IS_V7

`define SB_UP_PIPE nvs_ex_top.sb.up_core.pcie

  assign sb_up_Width      = 2'b01;
  assign sb_up_PCLK_Rate  = 3'b001;
  assign sb_up_Reset_n    = 1'b1; //`SB_DN_PIPE.pipe_tx_reset;
  assign sb_up_PowerDown  = `SB_UP_PIPE.pipe_tx0_powerdown_gt;
  assign sb_up_Rate       = {1'b0, `SB_UP_PIPE.pipe_tx_rate_gt};

  initial
  begin
    force `SB_UP_PIPE.sys_clk             = 1'b1; //to speed up simulation
    force `SB_UP_PIPE.pcie_top_i.pipe_clk  = sb_up_pclk;
    force `SB_UP_PIPE.pcie_top_i.user_clk  = clk250;
    force `SB_UP_PIPE.pcie_top_i.user_clk2 = clk250;
    force `SB_UP_PIPE.phy_rdy_n = rst;
    force sb_up_TxDeemph                  = `SB_UP_PIPE.pipe_tx_deemph_gt;
    force sb_up_TxMargin                  = `SB_UP_PIPE.pipe_tx_margin_gt;
    force sb_up_TxSwing                   = 1'b0;//`SB_DN_PIPE.pipe_txswing;
    force sb_up_TxDetectRxLoopback        = `SB_UP_PIPE.pipe_tx_rcvr_det_gt;
    
    force sb_up_TxData0                   = `SB_UP_PIPE.pipe_tx0_data_gt;
    force sb_up_TxDataK0                  = `SB_UP_PIPE.pipe_tx0_char_is_k_gt;
    force sb_up_TxDataValid0              = 1'b0; 
    force sb_up_TxStartBlock0             = 1'b0;
    force sb_up_TxElecIdle0               = `SB_UP_PIPE.pipe_tx0_elec_idle_gt;
    force sb_up_TxCompliance0             = `SB_UP_PIPE.pipe_tx0_compliance_gt;
    force sb_up_RxPolarity0               = `SB_UP_PIPE.pipe_rx0_polarity_gt;
    force `SB_UP_PIPE.pipe_rx0_phy_status_gt = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rx0_status_gt     = sb_up_RxStatus0;
    force `SB_UP_PIPE.pipe_rx0_data_gt       = sb_up_RxData0;
    force `SB_UP_PIPE.pipe_rx0_char_is_k_gt  = sb_up_RxDataK0;
    force `SB_UP_PIPE.pipe_rx0_valid_gt      = sb_up_RxValid0;
    force `SB_UP_PIPE.pipe_rx0_elec_idle_gt  = sb_up_RxElecIdle0;
    force `SB_UP_PIPE.pipe_rx0_chanisaligned_gt = sb_up_RxValid0;
    
    force sb_up_TxData1                   = `SB_UP_PIPE.pipe_tx1_data_gt;
    force sb_up_TxDataK1                  = `SB_UP_PIPE.pipe_tx1_char_is_k_gt;
    force sb_up_TxDataValid1              = 1'b0; 
    force sb_up_TxStartBlock1             = 1'b0;
    force sb_up_TxElecIdle1               = `SB_UP_PIPE.pipe_tx1_elec_idle_gt;
    force sb_up_TxCompliance1             = `SB_UP_PIPE.pipe_tx1_compliance_gt;
    force sb_up_RxPolarity1               = `SB_UP_PIPE.pipe_rx1_polarity_gt;
    force `SB_UP_PIPE.pipe_rx1_phy_status_gt = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rx1_status_gt     = sb_up_RxStatus1;
    force `SB_UP_PIPE.pipe_rx1_data_gt       = sb_up_RxData1;
    force `SB_UP_PIPE.pipe_rx1_char_is_k_gt  = sb_up_RxDataK1;
    force `SB_UP_PIPE.pipe_rx1_valid_gt      = sb_up_RxValid1;
    force `SB_UP_PIPE.pipe_rx1_elec_idle_gt  = sb_up_RxElecIdle1;
    force `SB_UP_PIPE.pipe_rx1_chanisaligned_gt = sb_up_RxValid1;
    
    force sb_up_TxData2                   = `SB_UP_PIPE.pipe_tx2_data_gt;
    force sb_up_TxDataK2                  = `SB_UP_PIPE.pipe_tx2_char_is_k_gt;
    force sb_up_TxDataValid2              = 1'b0; 
    force sb_up_TxStartBlock2             = 1'b0;
    force sb_up_TxElecIdle2               = `SB_UP_PIPE.pipe_tx2_elec_idle_gt;
    force sb_up_TxCompliance2             = `SB_UP_PIPE.pipe_tx2_compliance_gt;
    force sb_up_RxPolarity2               = `SB_UP_PIPE.pipe_rx2_polarity_gt;
    force `SB_UP_PIPE.pipe_rx2_phy_status_gt = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rx2_status_gt     = sb_up_RxStatus2;
    force `SB_UP_PIPE.pipe_rx2_data_gt       = sb_up_RxData2;
    force `SB_UP_PIPE.pipe_rx2_char_is_k_gt  = sb_up_RxDataK2;
    force `SB_UP_PIPE.pipe_rx2_valid_gt      = sb_up_RxValid2;
    force `SB_UP_PIPE.pipe_rx2_elec_idle_gt  = sb_up_RxElecIdle2;
    force `SB_UP_PIPE.pipe_rx2_chanisaligned_gt = sb_up_RxValid2;

    force sb_up_TxData3                   = `SB_UP_PIPE.pipe_tx3_data_gt;
    force sb_up_TxDataK3                  = `SB_UP_PIPE.pipe_tx3_char_is_k_gt;
    force sb_up_TxDataValid3              = 1'b0; 
    force sb_up_TxStartBlock3             = 1'b0;
    force sb_up_TxElecIdle3               = `SB_UP_PIPE.pipe_tx3_elec_idle_gt;
    force sb_up_TxCompliance3             = `SB_UP_PIPE.pipe_tx3_compliance_gt;
    force sb_up_RxPolarity3               = `SB_UP_PIPE.pipe_rx3_polarity_gt;
    force `SB_UP_PIPE.pipe_rx3_phy_status_gt = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rx3_status_gt     = sb_up_RxStatus3;
    force `SB_UP_PIPE.pipe_rx3_data_gt       = sb_up_RxData3;
    force `SB_UP_PIPE.pipe_rx3_char_is_k_gt  = sb_up_RxDataK3;
    force `SB_UP_PIPE.pipe_rx3_valid_gt      = sb_up_RxValid3;
    force `SB_UP_PIPE.pipe_rx3_elec_idle_gt  = sb_up_RxElecIdle3;
    force `SB_UP_PIPE.pipe_rx3_chanisaligned_gt = sb_up_RxValid3;

    force sb_up_TxData4                   = `SB_UP_PIPE.pipe_tx4_data_gt;
    force sb_up_TxDataK4                  = `SB_UP_PIPE.pipe_tx4_char_is_k_gt;
    force sb_up_TxDataValid4              = 1'b0; 
    force sb_up_TxStartBlock4             = 1'b0;
    force sb_up_TxElecIdle4               = `SB_UP_PIPE.pipe_tx4_elec_idle_gt;
    force sb_up_TxCompliance4             = `SB_UP_PIPE.pipe_tx4_compliance_gt;
    force sb_up_RxPolarity4               = `SB_UP_PIPE.pipe_rx4_polarity_gt;
    force `SB_UP_PIPE.pipe_rx4_phy_status_gt = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rx4_status_gt     = sb_up_RxStatus4;
    force `SB_UP_PIPE.pipe_rx4_data_gt       = sb_up_RxData4;
    force `SB_UP_PIPE.pipe_rx4_char_is_k_gt  = sb_up_RxDataK4;
    force `SB_UP_PIPE.pipe_rx4_valid_gt      = sb_up_RxValid4;
    force `SB_UP_PIPE.pipe_rx4_elec_idle_gt  = sb_up_RxElecIdle4;
    force `SB_UP_PIPE.pipe_rx4_chanisaligned_gt = sb_up_RxValid4;

    force sb_up_TxData5                   = `SB_UP_PIPE.pipe_tx5_data_gt;
    force sb_up_TxDataK5                  = `SB_UP_PIPE.pipe_tx5_char_is_k_gt;
    force sb_up_TxDataValid5              = 1'b0; 
    force sb_up_TxStartBlock5             = 1'b0;
    force sb_up_TxElecIdle5               = `SB_UP_PIPE.pipe_tx5_elec_idle_gt;
    force sb_up_TxCompliance5             = `SB_UP_PIPE.pipe_tx5_compliance_gt;
    force sb_up_RxPolarity5               = `SB_UP_PIPE.pipe_rx5_polarity_gt;
    force `SB_UP_PIPE.pipe_rx5_phy_status_gt = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rx5_status_gt     = sb_up_RxStatus5;
    force `SB_UP_PIPE.pipe_rx5_data_gt       = sb_up_RxData5;
    force `SB_UP_PIPE.pipe_rx5_char_is_k_gt  = sb_up_RxDataK5;
    force `SB_UP_PIPE.pipe_rx5_valid_gt      = sb_up_RxValid5;
    force `SB_UP_PIPE.pipe_rx5_elec_idle_gt  = sb_up_RxElecIdle5;
    force `SB_UP_PIPE.pipe_rx5_chanisaligned_gt = sb_up_RxValid5;

    force sb_up_TxData6                   = `SB_UP_PIPE.pipe_tx6_data_gt;
    force sb_up_TxDataK6                  = `SB_UP_PIPE.pipe_tx6_char_is_k_gt;
    force sb_up_TxDataValid6              = 1'b0; 
    force sb_up_TxStartBlock6             = 1'b0;
    force sb_up_TxElecIdle6               = `SB_UP_PIPE.pipe_tx6_elec_idle_gt;
    force sb_up_TxCompliance6             = `SB_UP_PIPE.pipe_tx6_compliance_gt;
    force sb_up_RxPolarity6               = `SB_UP_PIPE.pipe_rx6_polarity_gt;
    force `SB_UP_PIPE.pipe_rx6_phy_status_gt = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rx6_status_gt     = sb_up_RxStatus6;
    force `SB_UP_PIPE.pipe_rx6_data_gt       = sb_up_RxData6;
    force `SB_UP_PIPE.pipe_rx6_char_is_k_gt  = sb_up_RxDataK6;
    force `SB_UP_PIPE.pipe_rx6_valid_gt      = sb_up_RxValid6;
    force `SB_UP_PIPE.pipe_rx6_elec_idle_gt  = sb_up_RxElecIdle6;
    force `SB_UP_PIPE.pipe_rx6_chanisaligned_gt = sb_up_RxValid6;

    force sb_up_TxData7                   = `SB_UP_PIPE.pipe_tx7_data_gt;
    force sb_up_TxDataK7                  = `SB_UP_PIPE.pipe_tx7_char_is_k_gt;
    force sb_up_TxDataValid7              = 1'b0; 
    force sb_up_TxStartBlock7             = 1'b0;
    force sb_up_TxElecIdle7               = `SB_UP_PIPE.pipe_tx7_elec_idle_gt;
    force sb_up_TxCompliance7             = `SB_UP_PIPE.pipe_tx7_compliance_gt;
    force sb_up_RxPolarity7               = `SB_UP_PIPE.pipe_rx7_polarity_gt;
    force `SB_UP_PIPE.pipe_rx7_phy_status_gt = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rx7_status_gt     = sb_up_RxStatus7;
    force `SB_UP_PIPE.pipe_rx7_data_gt       = sb_up_RxData7;
    force `SB_UP_PIPE.pipe_rx7_char_is_k_gt  = sb_up_RxDataK7;
    force `SB_UP_PIPE.pipe_rx7_valid_gt      = sb_up_RxValid7;
    force `SB_UP_PIPE.pipe_rx7_elec_idle_gt  = sb_up_RxElecIdle7;
    force `SB_UP_PIPE.pipe_rx7_chanisaligned_gt = sb_up_RxValid7;
    
  end

`else // SB_UPLINK_IS_V7

//`define SB_UP_PIPE nvs_ex_top.sb.sw.usb.core.pcie.pcie_2_0_i.pcie_block_i
`define SB_UP_PIPE nvs_ex_top.sb.sw.usb.core.pcie.pcie_2_0_i

  assign sb_up_Rate       = `SB_UP_PIPE.PIPETXRATE;
  assign sb_up_Width      = `SB_UP_PIPE.pipe_width;
  assign sb_up_PCLK_Rate  = (`SB_UP_PIPE.PIPETXRATE == 2'b00) ? 3'b001 :  //Gen1: 16bit 125MHz
                            (`SB_UP_PIPE.PIPETXRATE == 2'b01) ? 3'b010 :  //Gen2: 16bit 250MHz
//                            (`SB_UP_PIPE.PIPETXRATE == 2'b10) ? 3'b010 :  //Gen3: 32bit 250Mhz
                            (`SB_UP_PIPE.PIPETXRATE == 2'b10) ? 3'b011 :  //Gen3: 16bit 500Mhz
                            3'b001;
  assign sb_up_Reset_n    = `SB_UP_PIPE.PIPETXRESET;
  assign sb_up_PowerDown  = `SB_UP_PIPE.PIPETX0POWERDOWN;

  initial
  begin
    force `SB_UP_PIPE.SYSCLK             = 1'b1; //to speed up simulation
    force `SB_UP_PIPE.PIPECLK           = sb_up_pclk;
    force sb_up_TxDeemph                  = `SB_UP_PIPE.PIPETXDEEMPH;
    force sb_up_TxMargin                  = `SB_UP_PIPE.PIPETXMARGIN;
    force sb_up_TxSwing                   = `SB_UP_PIPE.PIPETXSWING;
    force sb_up_TxDetectRxLoopback        = `SB_UP_PIPE.PIPETXDETECTRXLOOPBACK;
    
    force sb_up_TxData0                   = `SB_UP_PIPE.PIPETX0DATA;
    force sb_up_TxDataK0                  = `SB_UP_PIPE.PIPETX0CHARISK;
    force sb_up_TxDataValid0              = 1'b0;
    force sb_up_TxStartBlock0             = 1'b0;
    force sb_up_TxSyncHeader0             = `SB_UP_PIPE.PIPETX0SYNCHEADER;
    force sb_up_TxElecIdle0               = `SB_UP_PIPE.PIPETX0ELECIDLE;
    force sb_up_TxCompliance0             = `SB_UP_PIPE.PIPETX0COMPLIANCE;
    force sb_up_RxPolarity0               = `SB_UP_PIPE.PIPERX0POLARITY;
    force `SB_UP_PIPE.pipe_phystatus0     = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rxstatus0      = sb_up_RxStatus0;
    force `SB_UP_PIPE.pipe_rxdata0        = sb_up_RxData0;
    force `SB_UP_PIPE.pipe_rxdatak0       = sb_up_RxDataK0;
    force `SB_UP_PIPE.pipe_rxdatavalid0   = sb_up_RxDataValid0;
    force `SB_UP_PIPE.pipe_rxstartblock0  = sb_up_RxStartBlock0;
    force `SB_UP_PIPE.pipe_rxsyncheader0  = sb_up_RxSyncHeader0;
    force `SB_UP_PIPE.pipe_rxvalid0       = sb_up_RxValid0;
    force `SB_UP_PIPE.pipe_rxelecidle0    = sb_up_RxElecIdle0;
    
    force sb_up_TxData1                   = `SB_UP_PIPE.pipe_txdata1;
    force sb_up_TxDataK1                  = `SB_UP_PIPE.pipe_txdatak1;
    force sb_up_TxDataValid1              = `SB_UP_PIPE.pipe_txdatavalid1;
    force sb_up_TxStartBlock1             = `SB_UP_PIPE.pipe_txstartblock1;
    force sb_up_TxSyncHeader1             = `SB_UP_PIPE.pipe_txsyncheader1;
    force sb_up_TxElecIdle1               = `SB_UP_PIPE.pipe_txelecidle1;
    force sb_up_TxCompliance1             = `SB_UP_PIPE.pipe_txcompliance1;
    force sb_up_RxPolarity1               = `SB_UP_PIPE.pipe_rxpolarity1;
    force `SB_UP_PIPE.pipe_phystatus1     = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rxstatus1      = sb_up_RxStatus1;
    force `SB_UP_PIPE.pipe_rxdata1        = sb_up_RxData1;
    force `SB_UP_PIPE.pipe_rxdatak1       = sb_up_RxDataK1;
    force `SB_UP_PIPE.pipe_rxdatavalid1   = sb_up_RxDataValid1;
    force `SB_UP_PIPE.pipe_rxstartblock1  = sb_up_RxStartBlock1;
    force `SB_UP_PIPE.pipe_rxsyncheader1  = sb_up_RxSyncHeader1;
    force `SB_UP_PIPE.pipe_rxvalid1       = sb_up_RxValid1;
    force `SB_UP_PIPE.pipe_rxelecidle1    = sb_up_RxElecIdle1;
    
    force sb_up_TxData2                   = `SB_UP_PIPE.pipe_txdata2;
    force sb_up_TxDataK2                  = `SB_UP_PIPE.pipe_txdatak2;
    force sb_up_TxDataValid2              = `SB_UP_PIPE.pipe_txdatavalid2;
    force sb_up_TxStartBlock2             = `SB_UP_PIPE.pipe_txstartblock2;
    force sb_up_TxSyncHeader2             = `SB_UP_PIPE.pipe_txsyncheader2;
    force sb_up_TxElecIdle2               = `SB_UP_PIPE.pipe_txelecidle2;
    force sb_up_TxCompliance2             = `SB_UP_PIPE.pipe_txcompliance2;
    force sb_up_RxPolarity2               = `SB_UP_PIPE.pipe_rxpolarity2;
    force `SB_UP_PIPE.pipe_phystatus2     = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rxstatus2      = sb_up_RxStatus2;
    force `SB_UP_PIPE.pipe_rxdata2        = sb_up_RxData2;
    force `SB_UP_PIPE.pipe_rxdatak2       = sb_up_RxDataK2;
    force `SB_UP_PIPE.pipe_rxdatavalid2   = sb_up_RxDataValid2;
    force `SB_UP_PIPE.pipe_rxstartblock2  = sb_up_RxStartBlock2;
    force `SB_UP_PIPE.pipe_rxsyncheader2  = sb_up_RxSyncHeader2;
    force `SB_UP_PIPE.pipe_rxvalid2       = sb_up_RxValid2;
    force `SB_UP_PIPE.pipe_rxelecidle2    = sb_up_RxElecIdle2;
    
    force sb_up_TxData3                   = `SB_UP_PIPE.pipe_txdata3;
    force sb_up_TxDataK3                  = `SB_UP_PIPE.pipe_txdatak3;
    force sb_up_TxDataValid3              = `SB_UP_PIPE.pipe_txdatavalid3;
    force sb_up_TxStartBlock3             = `SB_UP_PIPE.pipe_txstartblock3;
    force sb_up_TxSyncHeader3             = `SB_UP_PIPE.pipe_txsyncheader3;
    force sb_up_TxElecIdle3               = `SB_UP_PIPE.pipe_txelecidle3;
    force sb_up_TxCompliance3             = `SB_UP_PIPE.pipe_txcompliance3;
    force sb_up_RxPolarity3               = `SB_UP_PIPE.pipe_rxpolarity3;
    force `SB_UP_PIPE.pipe_phystatus3     = sb_up_PhyStatus;
    force `SB_UP_PIPE.pipe_rxstatus3      = sb_up_RxStatus3;
    force `SB_UP_PIPE.pipe_rxdata3        = sb_up_RxData3;
    force `SB_UP_PIPE.pipe_rxdatak3       = sb_up_RxDataK3;
    force `SB_UP_PIPE.pipe_rxdatavalid3   = sb_up_RxDataValid3;
    force `SB_UP_PIPE.pipe_rxstartblock3  = sb_up_RxStartBlock3;
    force `SB_UP_PIPE.pipe_rxsyncheader3  = sb_up_RxSyncHeader3;
    force `SB_UP_PIPE.pipe_rxvalid3       = sb_up_RxValid3;
    force `SB_UP_PIPE.pipe_rxelecidle3    = sb_up_RxElecIdle3;
  end
`endif // SB_UPLINK_IS_V7
`endif // SB_UPLINK_IS_PIPE

  initial
  begin
    #100;	
    -> event_start_test;       // event to start test case
    start_test_case = 1'b1;	
  end

  always #`EX_8_0GHZ clk8000 = ~clk8000;
  always @(posedge clk8000) clk4000 = ~clk4000;
  always @(posedge clk4000) clk2000 = ~clk2000;
  always @(posedge clk2000) clk1000 = ~clk1000;
  always @(posedge clk1000) clk500 = ~clk500;
  always @(posedge clk500) clk250 = ~clk250;
  always @(posedge clk250) clk125 = ~clk125;
  always #`EX_5_0GHZ clk5000 = ~clk5000;
  always @(posedge clk5000) clk2500 = ~clk2500;
  always #25 clk200 = ~clk200;
  
`ifdef SB_UPLINK_IS_PIPE
  always @*
  begin
    if (rc_speed_gen3 === 1'b1)
      force rc_clk = clk1000;
    else if (rc_speed_gen2 === 1'b1)
      force rc_clk = clk500;
    else
      force rc_clk = clk250;
  end
`else  
  always @*
  begin
    if (rc_speed_gen3 === 1'b1)
      force rc_clk = clk8000;
    else if (rc_speed_gen2 === 1'b1)
      force rc_clk = clk5000;
    else
      force rc_clk = clk2500;
  end
`endif

`ifdef SB_DNLINK_IS_PIPE
  always @*
  begin
    if (ep_speed_gen3 === 1'b1)
      force ep_clk = clk1000;
    else if (ep_speed_gen2 === 1'b1)
      force ep_clk = clk500;
    else
      force ep_clk = clk250;
  end
`else  
  always @*
  begin
    if (ep_speed_gen3 === 1'b1)
      force ep_clk = clk8000;
    else if (ep_speed_gen2 === 1'b1)
      force ep_clk = clk5000;
    else
      force ep_clk = clk2500;
  end   
`endif
 
  initial
  begin
`ifndef SB_UPLINK_IS_PIPE  
    `p0.do_cfg(`EX_GEN3_ENABLE,1'b1);
`endif
`ifndef SB_DNLINK_IS_PIPE
    `p1.do_cfg(`EX_GEN2_ENABLE,1'b1);
`endif
    `CHK0.do_cfg(`EX_GEN3_ENABLE,1'b1);
    `MON0.do_cfg(`EX_GEN3_ENABLE,1'b1);
  end
   
  initial
  begin
    #1;                 //DK
    assign_handle;
    generate_start;
    `BFM0.config_param;
    
    endl="";
    if (|(print_msg_level&`EX_LOG))
	  begin
	    `MON0.header;
	  end
    if($test$plusargs("EX_DUMP"))
    begin
      $dumpvars(0,nvs_ex_top);    //option to dump wave form
	  end
    flg_end_done=0;
  end

  task set_msg_debug;
  begin
    print_msg_level = 4'hf;
    `BFM0.Pool.print_msg_level = 4'hf;
    `BFM0.print_msg_level = 4'hf;
    `MON0.print_msg_level = 4'hf;
    `MON0.mon_tx.print_msg_level = 4'hf;
    `MON0.mon_rx.print_msg_level = 4'hf;
    `CHK0.print_msg_level = 4'hf;
    `CHK0.TX.print_msg_level = 4'hf;
    `CHK0.RX.print_msg_level = 4'hf;
  end
  endtask
   //---------------------------------------------------------------------- 
   // task assign_handle;
   //---------------------------------------------------------------------- 
  task assign_handle;

      reg [31:0] handle0;
      reg [31:0] handle1;
      reg [31:0] handle2;
      reg [31:0] handle3;
      reg [31:0] handle4;
      
  begin
    handle0 = $fopen("tasks.log");
    handle1 = $fopen("rc.log");
    handle2 = $fopen("ep.log");
	 // Output UpLink to screen
    handle1[0] = 1'b1;
    report = handle1;
	  nvs_ex_tests.report = handle1;
	 // Output DnLink to screen
//    handle2[0] = 1'b1;
//    report = handle2;
//	  nvs_ex_tests.report = handle2;

    
    `BFM0.do_cfg(`EX_MODE_NVS_TASKS_FILE_HANDLE, handle0);
    `MON0.do_cfg(`EX_MODE_NVS_TASKS_FILE_HANDLE, handle0);
    `CHK0.do_cfg(`EX_MODE_NVS_TASKS_FILE_HANDLE, handle0);

    `BFM0.do_cfg(`EX_MODE_FILE_HANDLE,handle1);
    `MON0.do_cfg(`EX_MODE_FILE_HANDLE,handle1);
    `CHK0.do_cfg(`EX_MODE_FILE_HANDLE,handle1);
    
	  if($test$plusargs("EX_RAW"))
	  begin
	    handle3=$fopen("rc_raw.log");
      `MON0.do_cfg(`EX_MODE_RAW_FILE_HANDLE,handle3);
      `MON0.symbol_header;
	    handle4=$fopen("ep_raw.log");
    end
  end
  endtask // assign_handle
endmodule // top

